/usr/share/doc/libaws-doc/html/apiref.html is in libaws-doc 17.2.2017-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>13. AWS API Reference — AWS: Ada Web Server gpl-2017 documentation</title>
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: 'gpl-2017',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="12. References" href="rfc.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="rfc.html" title="12. References"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">AWS: Ada Web Server gpl-2017 documentation</a> »</li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/adacore_transparent.png" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">13. AWS API Reference</a><ul>
<li><a class="reference internal" href="#aws">13.1. AWS</a></li>
<li><a class="reference internal" href="#aws-attachments">13.2. AWS.Attachments</a></li>
<li><a class="reference internal" href="#aws-client">13.3. AWS.Client</a></li>
<li><a class="reference internal" href="#aws-client-hotplug">13.4. AWS.Client.Hotplug</a></li>
<li><a class="reference internal" href="#aws-communication">13.5. AWS.Communication</a></li>
<li><a class="reference internal" href="#aws-communication-client">13.6. AWS.Communication.Client</a></li>
<li><a class="reference internal" href="#aws-communication-server">13.7. AWS.Communication.Server</a></li>
<li><a class="reference internal" href="#aws-config">13.8. AWS.Config</a></li>
<li><a class="reference internal" href="#aws-config-ini">13.9. AWS.Config.Ini</a></li>
<li><a class="reference internal" href="#aws-config-set">13.10. AWS.Config.Set</a></li>
<li><a class="reference internal" href="#aws-containers-tables">13.11. AWS.Containers.Tables</a></li>
<li><a class="reference internal" href="#aws-cookie">13.12. AWS.Cookie</a></li>
<li><a class="reference internal" href="#aws-default">13.13. AWS.Default</a></li>
<li><a class="reference internal" href="#aws-dispatchers">13.14. AWS.Dispatchers</a></li>
<li><a class="reference internal" href="#aws-dispatchers-callback">13.15. AWS.Dispatchers.Callback</a></li>
<li><a class="reference internal" href="#aws-exceptions">13.16. AWS.Exceptions</a></li>
<li><a class="reference internal" href="#aws-headers">13.17. AWS.Headers</a></li>
<li><a class="reference internal" href="#aws-headers-values">13.18. AWS.Headers.Values</a></li>
<li><a class="reference internal" href="#aws-jabber">13.19. AWS.Jabber</a></li>
<li><a class="reference internal" href="#aws-ldap-client">13.20. AWS.LDAP.Client</a></li>
<li><a class="reference internal" href="#aws-log">13.21. AWS.Log</a></li>
<li><a class="reference internal" href="#aws-messages">13.22. AWS.Messages</a></li>
<li><a class="reference internal" href="#aws-mime">13.23. AWS.MIME</a></li>
<li><a class="reference internal" href="#aws-net">13.24. AWS.Net</a></li>
<li><a class="reference internal" href="#aws-net-buffered">13.25. AWS.Net.Buffered</a></li>
<li><a class="reference internal" href="#aws-net-log">13.26. AWS.Net.Log</a></li>
<li><a class="reference internal" href="#aws-net-log-callbacks">13.27. AWS.Net.Log.Callbacks</a></li>
<li><a class="reference internal" href="#aws-net-ssl">13.28. AWS.Net.SSL</a></li>
<li><a class="reference internal" href="#aws-net-ssl-certificate">13.29. AWS.Net.SSL.Certificate</a></li>
<li><a class="reference internal" href="#aws-net-websocket">13.30. AWS.Net.WebSocket</a></li>
<li><a class="reference internal" href="#aws-net-websocket-registry">13.31. AWS.Net.WebSocket.Registry</a></li>
<li><a class="reference internal" href="#aws-net-websocket-registry-control">13.32. AWS.Net.WebSocket.Registry.Control</a></li>
<li><a class="reference internal" href="#aws-parameters">13.33. AWS.Parameters</a></li>
<li><a class="reference internal" href="#aws-pop">13.34. AWS.POP</a></li>
<li><a class="reference internal" href="#aws-resources">13.35. AWS.Resources</a></li>
<li><a class="reference internal" href="#aws-resources-embedded">13.36. AWS.Resources.Embedded</a></li>
<li><a class="reference internal" href="#aws-resources-files">13.37. AWS.Resources.Files</a></li>
<li><a class="reference internal" href="#aws-resources-streams">13.38. AWS.Resources.Streams</a></li>
<li><a class="reference internal" href="#aws-resources-streams-disk">13.39. AWS.Resources.Streams.Disk</a></li>
<li><a class="reference internal" href="#aws-resources-streams-disk-once">13.40. AWS.Resources.Streams.Disk.Once</a></li>
<li><a class="reference internal" href="#aws-resources-streams-memory">13.41. AWS.Resources.Streams.Memory</a></li>
<li><a class="reference internal" href="#aws-resources-streams-memory-zlib">13.42. AWS.Resources.Streams.Memory.ZLib</a></li>
<li><a class="reference internal" href="#aws-resources-streams-pipe">13.43. AWS.Resources.Streams.Pipe</a></li>
<li><a class="reference internal" href="#aws-response">13.44. AWS.Response</a></li>
<li><a class="reference internal" href="#aws-server">13.45. AWS.Server</a></li>
<li><a class="reference internal" href="#aws-server-hotplug">13.46. AWS.Server.Hotplug</a></li>
<li><a class="reference internal" href="#aws-server-log">13.47. AWS.Server.Log</a></li>
<li><a class="reference internal" href="#aws-server-push">13.48. AWS.Server.Push</a></li>
<li><a class="reference internal" href="#aws-server-status">13.49. AWS.Server.Status</a></li>
<li><a class="reference internal" href="#aws-services-callbacks">13.50. AWS.Services.Callbacks</a></li>
<li><a class="reference internal" href="#aws-services-directory">13.51. AWS.Services.Directory</a></li>
<li><a class="reference internal" href="#aws-services-dispatchers">13.52. AWS.Services.Dispatchers</a></li>
<li><a class="reference internal" href="#aws-services-dispatchers-linker">13.53. AWS.Services.Dispatchers.Linker</a></li>
<li><a class="reference internal" href="#aws-services-dispatchers-method">13.54. AWS.Services.Dispatchers.Method</a></li>
<li><a class="reference internal" href="#aws-services-dispatchers-uri">13.55. AWS.Services.Dispatchers.URI</a></li>
<li><a class="reference internal" href="#aws-services-dispatchers-virtual-host">13.56. AWS.Services.Dispatchers.Virtual_Host</a></li>
<li><a class="reference internal" href="#aws-services-download">13.57. AWS.Services.Download</a></li>
<li><a class="reference internal" href="#aws-services-page-server">13.58. AWS.Services.Page_Server</a></li>
<li><a class="reference internal" href="#aws-services-split-pages">13.59. AWS.Services.Split_Pages</a></li>
<li><a class="reference internal" href="#aws-services-split-pages-alpha">13.60. AWS.Services.Split_Pages.Alpha</a></li>
<li><a class="reference internal" href="#aws-services-split-pages-alpha-bounded">13.61. AWS.Services.Split_Pages.Alpha.Bounded</a></li>
<li><a class="reference internal" href="#aws-services-split-pages-uniform">13.62. AWS.Services.Split_Pages.Uniform</a></li>
<li><a class="reference internal" href="#aws-services-split-pages-uniform-alpha">13.63. AWS.Services.Split_Pages.Uniform.Alpha</a></li>
<li><a class="reference internal" href="#aws-services-split-pages-uniform-overlapping">13.64. AWS.Services.Split_Pages.Uniform.Overlapping</a></li>
<li><a class="reference internal" href="#aws-services-transient-pages">13.65. AWS.Services.Transient_Pages</a></li>
<li><a class="reference internal" href="#aws-services-web-block">13.66. AWS.Services.Web_Block</a></li>
<li><a class="reference internal" href="#aws-services-web-block-context">13.67. AWS.Services.Web_Block.Context</a></li>
<li><a class="reference internal" href="#aws-services-web-block-registry">13.68. AWS.Services.Web_Block.Registry</a></li>
<li><a class="reference internal" href="#aws-session">13.69. AWS.Session</a></li>
<li><a class="reference internal" href="#aws-smtp">13.70. AWS.SMTP</a></li>
<li><a class="reference internal" href="#aws-smtp-client">13.71. AWS.SMTP.Client</a></li>
<li><a class="reference internal" href="#aws-status">13.72. AWS.Status</a></li>
<li><a class="reference internal" href="#aws-templates">13.73. AWS.Templates</a></li>
<li><a class="reference internal" href="#aws-translator">13.74. AWS.Translator</a></li>
<li><a class="reference internal" href="#aws-url">13.75. AWS.URL</a></li>
<li><a class="reference internal" href="#soap">13.76. SOAP</a></li>
<li><a class="reference internal" href="#soap-client">13.77. SOAP.Client</a></li>
<li><a class="reference internal" href="#soap-dispatchers">13.78. SOAP.Dispatchers</a></li>
<li><a class="reference internal" href="#soap-dispatchers-callback">13.79. SOAP.Dispatchers.Callback</a></li>
<li><a class="reference internal" href="#soap-message">13.80. SOAP.Message</a></li>
<li><a class="reference internal" href="#soap-message-xml">13.81. SOAP.Message.XML</a></li>
<li><a class="reference internal" href="#soap-parameters">13.82. SOAP.Parameters</a></li>
<li><a class="reference internal" href="#soap-types">13.83. SOAP.Types</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="rfc.html"
title="previous chapter">12. References</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/apiref.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="aws-api-reference">
<h1>13. AWS API Reference<a class="headerlink" href="#aws-api-reference" title="Permalink to this headline">¶</a></h1>
<div class="section" id="aws">
<span id="id1"></span><h2>13.1. AWS<a class="headerlink" href="#aws" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2017, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS</span> <span class="nc">with</span> <span class="nc">Pure</span> <span class="kr">is</span>
<span class="no">Version</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"gpl-2017"</span><span class="p">;</span>
<span class="no">HTTP_10</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"HTTP/1.0"</span><span class="p">;</span>
<span class="no">HTTP_11</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"HTTP/1.1"</span><span class="p">;</span>
<span class="n">HTTP_Version</span> <span class="p">:</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">HTTP_11</span><span class="p">;</span>
<span class="kr">end</span> <span class="nf">AWS</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-attachments">
<span id="id2"></span><h2>13.2. AWS.Attachments<a class="headerlink" href="#aws-attachments" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-0"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Headers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.MIME</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Vectors</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Attachments</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Element</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">List</span> <span class="kr">is</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="no">Empty_List</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">List</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Content</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Encoding</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">None</span><span class="p">,</span> <span class="nv">Base64</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">File</span>
<span class="p">(</span><span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Encoding</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">;</span>
<span class="nv">Content_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_Plain</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Content</span><span class="p">;</span>
<span class="c1">-- A filename as content, if Encode is set to Base64 the file content will</span>
<span class="c1">-- be base64 encoded.</span>
<span class="kd">function</span> <span class="nf">Value</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Encoding</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">;</span>
<span class="nv">Content_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_Plain</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Content</span><span class="p">;</span>
<span class="c1">-- A string as content</span>
<span class="kd">type</span> <span class="kt">Attachment_Kind</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Data</span><span class="p">,</span> <span class="nv">Alternative</span><span class="p">);</span>
<span class="c1">-- Data : for a standard MIME attachment</span>
<span class="c1">-- Alternative : for a set of alternative content</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Content_Id</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">List</span> <span class="p">:=</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">Empty_List</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Encoding</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">)</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">'</span><span class="na">Old</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">-- Adds an Attachment to the list.</span>
<span class="c1">-- Note that the encoding will overwrite the corresponding entry in</span>
<span class="c1">-- headers.</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Encoding</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">)</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">'</span><span class="na">Old</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">-- Adds an Attachment to the list.</span>
<span class="c1">-- Note that the encoding will overwrite the corresponding entry in</span>
<span class="c1">-- headers.</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Content</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">List</span> <span class="p">:=</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">Empty_List</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">)</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">'</span><span class="na">Old</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">-- Adds an Attachment to the list.</span>
<span class="c1">-- Note that the encoding and content type attached to Data will</span>
<span class="c1">-- overwrite the corresponding entry in headers.</span>
<span class="c1">-- Alternatives content</span>
<span class="kd">type</span> <span class="kt">Alternatives</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Parts</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Alternatives</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Content</span><span class="p">);</span>
<span class="c1">-- Add an alternative content</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span>
<span class="nv">Parts</span> <span class="p">: </span><span class="nv">Alternatives</span><span class="p">);</span>
<span class="c1">-- Add an alternative group to the current attachment list</span>
<span class="kd">procedure</span> <span class="nf">Reset</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span>
<span class="nv">Delete_Files</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">)</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Reset the list to be empty. If Delete_Files is set to true the</span>
<span class="c1">-- attached files are removed from the file system.</span>
<span class="kd">function</span> <span class="nf">Count</span> <span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the number of Attachments in the data</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Element</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">);</span>
<span class="c1">-- Returns specified Attachment</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Content_Id</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Element</span>
<span class="kn">with</span>
<span class="nn">Pre</span> <span class="p">=></span>
<span class="p">(</span><span class="kr">for</span> <span class="n">some</span> <span class="n">K</span> <span class="ow">in</span> <span class="mi">1</span> <span class="p">..</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">)</span>
<span class="p">=></span> <span class="n">AWS</span><span class="p">.</span><span class="n">Attachments</span><span class="p">.</span><span class="n">Content_Id</span> <span class="p">(</span><span class="n">Get</span> <span class="p">(</span><span class="n">Attachments</span><span class="p">,</span> <span class="n">K</span><span class="p">))</span> <span class="o">=</span> <span class="n">Content_Id</span><span class="p">);</span>
<span class="c1">-- Returns the Attachment with the Content Id</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">Attachment</span> <span class="p">:</span> <span class="n">Element</span><span class="p">;</span>
<span class="n">Index</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Attachment</span> <span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">);</span>
<span class="c1">-- Calls action for every Attachment in Message. Stop iterator if Quit is</span>
<span class="c1">-- set to True, Quit is set to False by default.</span>
<span class="kd">procedure</span> <span class="nf">Iterate</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Process</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">procedure</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">));</span>
<span class="c1">-- Calls Process for every Attachment in Message</span>
<span class="kd">function</span> <span class="nf">Headers</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">)</span> <span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Headers</span><span class="p">.</span><span class="n">List</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the list of header lines for the attachment</span>
<span class="kd">function</span> <span class="nf">Content_Type</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Get value for "Content-Type:" header</span>
<span class="kd">function</span> <span class="nf">Content_Id</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns Attachment's content id</span>
<span class="kd">function</span> <span class="nf">Local_Filename</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the local filename of the Attachment.</span>
<span class="c1">-- Local filename is the name the receiver used when extracting the</span>
<span class="c1">-- Attachment into a file.</span>
<span class="kd">function</span> <span class="nf">Filename</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Original filename on the server side. This is generally encoded on the</span>
<span class="c1">-- content-type or content-disposition header.</span>
<span class="kd">function</span> <span class="nf">Kind</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">Element</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Attachment_Kind</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the kind of the given attachment</span>
<span class="kd">function</span> <span class="nf">Length</span>
<span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Boundary</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Length</span><span class="p">'</span><span class="na">Result</span> <span class="o">></span> <span class="mi">8</span><span class="p">;</span>
<span class="c1">-- Returns the complete size of all attachments including the surrounding</span>
<span class="c1">-- boundaries.</span>
<span class="kd">procedure</span> <span class="nf">Send_MIME_Header</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Boundary</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Alternative</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Output MIME header, returns the boundary for the content</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Boundary</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Send all Attachments, including the surrounding boundarys, in the list</span>
<span class="c1">-- to the socket.</span>
<span class="kd">type</span> <span class="kt">Root_MIME_Kind</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Multipart_Mixed</span><span class="p">,</span> <span class="nv">Multipart_Alternative</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Root_MIME</span> <span class="p">(</span><span class="nv">Attachments</span> <span class="p">: </span><span class="nv">List</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Root_MIME_Kind</span><span class="p">;</span>
<span class="c1">-- Returns the root MIME kind for the given attachment list</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Attachments</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-client">
<span id="id3"></span><h2>13.3. AWS.Client<a class="headerlink" href="#aws-client" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-1"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Attachments</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Default</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Headers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net.SSL.Certificate</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Real_Time</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">ZLib</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.URL</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Client</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">Connection_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised if the connection with the server cannot be established</span>
<span class="n">Protocol_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised if the client receives wrong HTTP protocol data</span>
<span class="no">No_Data</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Used as the default parameter when no data specified for a specific</span>
<span class="c1">-- parameter.</span>
<span class="no">Retry_Default</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Number of time a data is requested from the Server if the first</span>
<span class="c1">-- time fails.</span>
<span class="c1">--------------</span>
<span class="c1">-- Timeouts --</span>
<span class="c1">--------------</span>
<span class="kd">type</span> <span class="kt">Timeouts_Values</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Defined the duration for the connect, send, receive and complete</span>
<span class="c1">-- response receive timeouts.</span>
<span class="no">No_Timeout</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Timeouts_Values</span><span class="p">;</span>
<span class="c1">-- No timeout, allow infinite time to send or retrieve data</span>
<span class="kd">function</span> <span class="nf">Timeouts</span>
<span class="p">(</span><span class="nv">Connect</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Forever</span><span class="p">;</span>
<span class="nv">Send</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Forever</span><span class="p">;</span>
<span class="nv">Receive</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Forever</span><span class="p">;</span>
<span class="nv">Response</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Forever</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Timeouts_Values</span><span class="p">;</span>
<span class="c1">-- Constructor for the timeouts values</span>
<span class="kd">function</span> <span class="nf">Timeouts</span> <span class="p">(</span><span class="nv">Each</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Timeouts_Values</span><span class="p">;</span>
<span class="c1">-- Constructor for the timeouts values, sets all timeouts values (see</span>
<span class="c1">-- Contructor above) to Each.</span>
<span class="kd">function</span> <span class="nf">Connect_Timeout</span> <span class="p">(</span><span class="nv">T</span> <span class="p">: </span><span class="nv">Timeouts_Values</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the corresponding timeout value</span>
<span class="kd">function</span> <span class="nf">Send_Timeout</span> <span class="p">(</span><span class="nv">T</span> <span class="p">: </span><span class="nv">Timeouts_Values</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the corresponding timeout value</span>
<span class="kd">function</span> <span class="nf">Receive_Timeout</span> <span class="p">(</span><span class="nv">T</span> <span class="p">: </span><span class="nv">Timeouts_Values</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the corresponding timeout value</span>
<span class="kd">function</span> <span class="nf">Response_Timeout</span> <span class="p">(</span><span class="nv">T</span> <span class="p">: </span><span class="nv">Timeouts_Values</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the corresponding timeout value</span>
<span class="c1">--------------</span>
<span class="c1">-- Messages --</span>
<span class="c1">--------------</span>
<span class="kd">type</span> <span class="kt">Content_Bound</span> <span class="kr">is</span> <span class="kr">new</span> <span class="kt">Integer</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">1</span> <span class="p">..</span> <span class="kt">Integer</span><span class="p">'</span><span class="na">Last</span><span class="p">;</span>
<span class="no">Undefined</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Content_Bound</span> <span class="p">:=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Content_Range</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">First</span><span class="p">,</span> <span class="n">Last</span> <span class="p">:</span> <span class="n">Content_Bound</span> <span class="p">:=</span> <span class="n">Undefined</span><span class="p">;</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="c1">-- Range for partial download</span>
<span class="no">No_Range</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Content_Range</span> <span class="p">:=</span> <span class="p">(</span><span class="n">Undefined</span><span class="p">,</span> <span class="n">Undefined</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Authentication_Mode</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Authentication_Mode</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Authentication_Level</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Authentication_Type</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Auth_Attempts_Count</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Header_List</span> <span class="kr">is</span> <span class="n">Headers</span><span class="p">.</span><span class="n">List</span><span class="p">;</span>
<span class="no">Empty_Header_List</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Header_List</span> <span class="p">:=</span> <span class="n">Headers</span><span class="p">.</span><span class="n">Empty_List</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Attachment_List</span> <span class="kr">is</span> <span class="n">Attachments</span><span class="p">.</span><span class="n">List</span><span class="p">;</span>
<span class="no">Empty_Attachment_List</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Attachment_List</span> <span class="p">:=</span> <span class="n">Attachments</span><span class="p">.</span><span class="n">Empty_List</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Data_Range</span> <span class="p">: </span><span class="nv">Content_Range</span> <span class="p">:=</span> <span class="nv">No_Range</span><span class="p">;</span>
<span class="nv">Follow_Redirection</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Certificate</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Client_Certificate</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Retrieve the message data given a specific URL. It open a connection</span>
<span class="c1">-- with the server and ask for the resource specified in the URL it then</span>
<span class="c1">-- return it in the Response.Data structure.</span>
<span class="c1">-- If User/Pwd are given then it uses it to access the URL.</span>
<span class="c1">--</span>
<span class="c1">-- Eventually it connect through a PROXY using if necessary the Proxy</span>
<span class="c1">-- authentication Proxy_User:Proxy_Pwd.</span>
<span class="c1">--</span>
<span class="c1">-- Only Basic authentication is supported (i.e. Digest is not). Digest</span>
<span class="c1">-- authentication is supported with the keep-alive client API, see below.</span>
<span class="c1">--</span>
<span class="c1">-- If Follow_Redirection is set to True, Get will follow the redirection</span>
<span class="c1">-- information for 301 status code response. Note that this is not</span>
<span class="c1">-- supported for keep-alive connections as the redirection could point to</span>
<span class="c1">-- another server.</span>
<span class="c1">--</span>
<span class="c1">-- Get will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Head</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Idem as above but we do not get the message body.</span>
<span class="c1">-- Head will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Put</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Send to the server URL a PUT request with Data</span>
<span class="c1">-- Put will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Delete</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Send to the server URL a DELETE request with Data</span>
<span class="c1">-- Delete will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Delete</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Send to the server URL a DELETE request with Data</span>
<span class="c1">-- Delete will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Post</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_List</span> <span class="p">:=</span> <span class="nv">Empty_Attachment_List</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Send to the server URL a POST request with Data</span>
<span class="c1">-- Post will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Post</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_List</span> <span class="p">:=</span> <span class="nv">Empty_Attachment_List</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Idem as above but with binary data</span>
<span class="kd">function</span> <span class="nf">SOAP_Post</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_List</span> <span class="p">:=</span> <span class="nv">Empty_Attachment_List</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Send to the server URL a POST request with Data</span>
<span class="c1">-- Post will retry one time if it fails.</span>
<span class="kd">function</span> <span class="nf">Upload</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">;</span>
<span class="nv">Progress</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">procedure</span>
<span class="p">(</span><span class="nv">Total</span><span class="p">,</span> <span class="nv">Sent</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="p">:=</span> <span class="kc">null</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- This is a file upload request. Filename file's content will be send to</span>
<span class="c1">-- the server at address URL.</span>
<span class="c1">---------------------------------------</span>
<span class="c1">-- Keep-Alive client implementation --</span>
<span class="c1">---------------------------------------</span>
<span class="kd">type</span> <span class="kt">HTTP_Connection</span> <span class="kr">is</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Create</span>
<span class="p">(</span><span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Retry</span> <span class="p">: </span><span class="nv">Natural</span> <span class="p">:=</span> <span class="nv">Retry_Default</span><span class="p">;</span>
<span class="nv">Persistent</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Server_Push</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Certificate</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Client_Certificate</span><span class="p">;</span>
<span class="nv">User_Agent</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">User_Agent</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">HTTP_Connection</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Create</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Retry</span> <span class="p">: </span><span class="nv">Natural</span> <span class="p">:=</span> <span class="nv">Retry_Default</span><span class="p">;</span>
<span class="nv">Persistent</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Server_Push</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">SSL_Config</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">SSL</span><span class="p">.</span><span class="nv">Config</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">SSL</span><span class="p">.</span><span class="nv">Null_Config</span><span class="p">;</span>
<span class="nv">Certificate</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Client_Certificate</span><span class="p">;</span>
<span class="nv">User_Agent</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">User_Agent</span><span class="p">);</span>
<span class="c1">-- Create a new connection. This is to be used with Keep-Alive client API</span>
<span class="c1">-- below. The connection will be tried Retry times if it fails. If</span>
<span class="c1">-- persistent is True the connection will remain open otherwise it will be</span>
<span class="c1">-- closed after each request. User/Pwd are the server authentication info,</span>
<span class="c1">-- Proxy is the name of the proxy server to use, Proxy_User/Proxy_Pwd are</span>
<span class="c1">-- the proxy authentication data. Only Basic authentication is supported</span>
<span class="c1">-- from this routine, for Digest authentication see below. Timeouts are</span>
<span class="c1">-- the send/receive timeouts for each request. If Server_Push is True the</span>
<span class="c1">-- connection will be used to push information to the client.</span>
<span class="c1">-- SSL_Config is to define secure connection configuration. Othewhise</span>
<span class="c1">-- Certificate can be set to specify the certificate filename to use for</span>
<span class="c1">-- the secure connection. User_Agent can be overridden to whatever you want</span>
<span class="c1">-- the client interface to present itself to the server.</span>
<span class="kd">function</span> <span class="nf">Get_Certificate</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Net</span><span class="p">.</span><span class="n">SSL</span><span class="p">.</span><span class="n">Certificate</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Return the certificate used for the secure connection. If this is not a</span>
<span class="c1">-- secure connection, returns Net.SSL.Certificate.Undefined.</span>
<span class="kd">function</span> <span class="nf">Host</span> <span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the host as recorded into the connection</span>
<span class="kd">procedure</span> <span class="nf">Set_Headers</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span> <span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Set additional headers for connection</span>
<span class="kd">procedure</span> <span class="nf">Set_WWW_Authentication</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Authentication_Mode</span><span class="p">);</span>
<span class="c1">-- Sets the username password and authentication mode for the Web</span>
<span class="c1">-- authentication.</span>
<span class="c1">--</span>
<span class="c1">-- "Any" mean that user want to use Digest server authentication mode but</span>
<span class="c1">-- could use Basic if the server does not support Digest authentication.</span>
<span class="c1">--</span>
<span class="c1">-- "Basic" mean that client will send basic authentication. "Basic"</span>
<span class="c1">-- authentication is send with the first request and is a fast</span>
<span class="c1">-- authentication protocol.</span>
<span class="c1">--</span>
<span class="c1">-- "Digest" mean that the client ask for Digest authentication, it</span>
<span class="c1">-- requires that a first unauthorized request be sent to the server. The</span>
<span class="c1">-- server will answer "nonce" for the authentication protocol to continue.</span>
<span class="kd">procedure</span> <span class="nf">Set_Proxy_Authentication</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Authentication_Mode</span><span class="p">);</span>
<span class="c1">-- Sets the username, password and authentication mode for the proxy</span>
<span class="c1">-- authentication.</span>
<span class="kd">procedure</span> <span class="nf">Set_Persistent</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Change Persistent flag of the connection. If persistent is True the</span>
<span class="c1">-- connection will remain open, otherwise it will be closed after each</span>
<span class="c1">-- request, next request and further would be with "Connection: Close"</span>
<span class="c1">-- header line.</span>
<span class="kd">procedure</span> <span class="nf">Clear_SSL_Session</span> <span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">);</span>
<span class="c1">-- Avoid reuse SSL session data after reconnect</span>
<span class="kd">procedure</span> <span class="nf">Copy_Cookie</span>
<span class="p">(</span><span class="nv">Source</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Destination</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">);</span>
<span class="c1">-- Copy a session Id from connection Source to connection Destination.</span>
<span class="c1">-- Allow both connections to share the same user environment. Note that</span>
<span class="c1">-- user's environment are thread-safe.</span>
<span class="kd">function</span> <span class="nf">Get_Cookie</span> <span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get the connection cookie</span>
<span class="kd">procedure</span> <span class="nf">Set_Cookie</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span> <span class="nv">Cookie</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Set the connection cookie</span>
<span class="kd">function</span> <span class="nf">Cipher_Description</span> <span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">SSL_Session_Id</span> <span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns base64 encoded SSL session identifier.</span>
<span class="c1">-- Returns empty string for plain HTTP connections and for not connected</span>
<span class="c1">-- SSL HTTP connections.</span>
<span class="kd">function</span> <span class="nf">Read_Until</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Delimiter</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Wait</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Read data on the Connection until the delimiter (including the</span>
<span class="c1">-- delimiter). It can be used to retrieve the next piece of data from a</span>
<span class="c1">-- push server. If Wait is False the routine is looking for delimiter only</span>
<span class="c1">-- in the internal socket buffer and return empty string if no delimiter</span>
<span class="c1">-- found. If Wait is True and returned data is empty or does not termintate</span>
<span class="c1">-- with the delimiter the server push connection is closed.</span>
<span class="kd">procedure</span> <span class="nf">Read_Until</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Delimiter</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Wait</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">);</span>
<span class="c1">-- Idem as above but returns the result as an Unbounded_String</span>
<span class="kd">procedure</span> <span class="nf">Read_Some</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Reads any available data from the client's connection.</span>
<span class="c1">-- If no data available, it will wait for some data to become available or</span>
<span class="c1">-- until it timeouts. Returns Last < Data'First when there is no data</span>
<span class="c1">-- available in the HTTP response. Connection have to be created with</span>
<span class="c1">-- parameter Server_Push => True.</span>
<span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Reads data from the client's connection until Data buffer if filled</span>
<span class="c1">-- or it reached the end of the response. Returns Last < Data'Last if</span>
<span class="c1">-- there is no more data available in HTTP response. Connection have</span>
<span class="c1">-- to be created with parameter Server_Push => True.</span>
<span class="kd">procedure</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Data_Range</span> <span class="p">: </span><span class="nv">Content_Range</span> <span class="p">:=</span> <span class="nv">No_Range</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Get above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Head</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Head above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Delete</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Delete above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Delete</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Delete above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Put</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Put above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Put</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Post</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_List</span> <span class="p">:=</span> <span class="nv">Empty_Attachment_List</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Post above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Post</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_List</span> <span class="p">:=</span> <span class="nv">Empty_Attachment_List</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as Post above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">Upload</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_Data</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">;</span>
<span class="nv">Progress</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">procedure</span>
<span class="p">(</span><span class="nv">Total</span><span class="p">,</span> <span class="nv">Sent</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="p">:=</span> <span class="kc">null</span><span class="p">);</span>
<span class="c1">-- Same as Upload above but using a Connection</span>
<span class="kd">procedure</span> <span class="nf">SOAP_Post</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Streaming</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_List</span> <span class="p">:=</span> <span class="nv">Empty_Attachment_List</span><span class="p">;</span>
<span class="nv">Headers</span> <span class="p">: </span><span class="nv">Header_List</span> <span class="p">:=</span> <span class="nv">Empty_Header_List</span><span class="p">);</span>
<span class="c1">-- Same as SOAP_Post above but using a Connection</span>
<span class="c1">-- Streaming is to be able to parse response XML on the fly,</span>
<span class="c1">-- without intermediate buffer.</span>
<span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">);</span>
<span class="c1">-- Close connection, it releases all associated resources</span>
<span class="kd">procedure</span> <span class="nf">Set_Streaming_Output</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Call this routine with Value => True to be able to read data as a</span>
<span class="c1">-- stream by using Read and/or Read_Some routines above. Note that</span>
<span class="c1">-- Connection is already in Streaming mode if it has been created</span>
<span class="c1">-- with Server_Push => True.</span>
<span class="kd">procedure</span> <span class="nf">Set_Debug</span> <span class="p">(</span><span class="nv">On</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Set debug mode on/off. If debug is activated the request header and the</span>
<span class="c1">-- server response header will be displayed.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Client</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-client-hotplug">
<span id="id4"></span><h2>13.4. AWS.Client.Hotplug<a class="headerlink" href="#aws-client-hotplug" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-2"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Client.Hotplug</span> <span class="kr">is</span>
<span class="c1">-- Below are two routines to register/unregister hotplug modules into</span>
<span class="c1">-- server. Note that such server must be configured to accept hotplug</span>
<span class="c1">-- modules. Password parameter is the clear text paswword, it will be sent</span>
<span class="c1">-- encoded. An authorization entry for module Name with Password (and the</span>
<span class="c1">-- given URL host for registration) must be found in the server's</span>
<span class="c1">-- authorization file. See AWS.Server.Hotplug.Activate.</span>
<span class="kd">function</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Server</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Regexp</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Register hotplug module Name into Server with address URL to respond to</span>
<span class="c1">-- requests matching Regexp. Server must be a valid URL, http://host:port.</span>
<span class="c1">-- If port is not specified the default HTTP port is used.</span>
<span class="kd">function</span> <span class="nf">Unregister</span>
<span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Server</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Regexp</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Unregister hotplug module Name responding to Regexp requests from</span>
<span class="c1">-- Server. See comment above about Password.</span>
<span class="kr">end</span> <span class="nf">AWS.Client.Hotplug</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-communication">
<span id="id5"></span><h2>13.5. AWS.Communication<a class="headerlink" href="#aws-communication" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-3"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- The communication protocol uses a light encoding scheme based on the HTTP</span>
<span class="c1">-- GET method. For standard, XML based, communication you can use the SOAP</span>
<span class="c1">-- protocol. This API can be convenient if you do not plan to build AWS with</span>
<span class="c1">-- SOAP support.</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Communication</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Parameter_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="no">Null_Parameter_Set</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Parameter_Set</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Parameters</span>
<span class="p">(</span><span class="nv">P1</span><span class="p">,</span> <span class="nv">P2</span><span class="p">,</span> <span class="nv">P3</span><span class="p">,</span> <span class="nv">P4</span><span class="p">,</span> <span class="nv">P5</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Parameter_Set</span><span class="p">;</span>
<span class="c1">-- Constructor function to help create a Parameter_Set. This function will</span>
<span class="c1">-- return a Parameter_Set array containing any parameter with a non emptry</span>
<span class="c1">-- string value.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Communication</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-communication-client">
<span id="id6"></span><h2>13.6. AWS.Communication.Client<a class="headerlink" href="#aws-communication-client" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-4"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Communication.Client</span> <span class="kr">is</span>
<span class="kd">function</span> <span class="nf">Send_Message</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Parameters</span> <span class="p">: </span><span class="nv">Parameter_Set</span> <span class="p">:=</span> <span class="nv">Null_Parameter_Set</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Send a message to server with a set of parameters. The destination is</span>
<span class="c1">-- server is http://Server:Port, the message name is Name and the set of</span>
<span class="c1">-- parameters is to be found into Parameters.</span>
<span class="c1">--</span>
<span class="c1">-- The complete message format is:</span>
<span class="c1">--</span>
<span class="c1">-- http://<Server>:<Port>/AWS_Com?HOST=<host>&NAME=<name></span>
<span class="c1">-- &P1=<param1>&P2=<param2></span>
<span class="kr">end</span> <span class="nf">AWS.Communication.Client</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-communication-server">
<span id="id7"></span><h2>13.7. AWS.Communication.Server<a class="headerlink" href="#aws-communication-server" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-5"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kd">generic</span>
<span class="kd">type</span> <span class="kt">T</span> <span class="p">(<>)</span> <span class="kr">is</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span> <span class="c1">-- Data type received by this server</span>
<span class="kd">type</span> <span class="kt">T_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="n">T</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">function</span> <span class="n">Callback</span>
<span class="p">(</span><span class="n">Server</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span> <span class="c1">-- Host name</span>
<span class="n">Name</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span> <span class="c1">-- Message name</span>
<span class="n">Context</span> <span class="p">:</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span> <span class="n">T</span><span class="p">;</span>
<span class="n">Parameters</span> <span class="p">:</span> <span class="n">Parameter_Set</span> <span class="p">:=</span> <span class="n">Null_Parameter_Set</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Communication.Server</span> <span class="kr">is</span>
<span class="c1">-- Each instantiation of this package will create an HTTP server waiting</span>
<span class="c1">-- for incoming requests at the Port specified in the Start formal</span>
<span class="c1">-- parameter. This communication server must be started with the Start</span>
<span class="c1">-- procedure and can be stopped with the procedure Shutdown below.</span>
<span class="kd">procedure</span> <span class="nf">Start</span> <span class="p">(</span><span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span> <span class="nv">Context</span> <span class="p">: </span><span class="nv">T_Access</span><span class="p">;</span> <span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Start communication HTTP server listening at the given port</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span><span class="p">;</span>
<span class="c1">-- Shutdown the communication HTTP server</span>
<span class="kr">end</span> <span class="nf">AWS.Communication.Server</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-config">
<span id="id8"></span><h2>13.8. AWS.Config<a class="headerlink" href="#aws-config" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-6"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package provide an easy way to handle server configuration options.</span>
<span class="c1">--</span>
<span class="c1">-- If initialization of this package is not done all functions below will</span>
<span class="c1">-- return the default value as declared in AWS.Default.</span>
<span class="kn">with</span> <span class="nn">System</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">GNAT.Regexp</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Containers.String_Vectors</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Default</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Config</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="no">Default_Config</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Object</span><span class="p">;</span>
<span class="c1">-- For the external configuration to be loaded either Get_Current or</span>
<span class="c1">-- Load_Config must be called explicitely.</span>
<span class="kd">function</span> <span class="nf">Get_Current</span> <span class="nf">return</span> <span class="nf">Object</span><span class="p">;</span>
<span class="c1">-- Returns a configuration record. This is the properties as read in files</span>
<span class="c1">-- 'aws.ini' and 'progname.ini'. This configuration object holds only the</span>
<span class="c1">-- per-server options.</span>
<span class="kd">procedure</span> <span class="nf">Load_Config</span><span class="p">;</span>
<span class="c1">-- Load configuration and store it into an internal object. This can be</span>
<span class="c1">-- called when only some server-wide configuration are to be set from</span>
<span class="c1">-- .ini files for example.</span>
<span class="c1">------------------------</span>
<span class="c1">-- Per Server options --</span>
<span class="c1">------------------------</span>
<span class="c1">------------</span>
<span class="c1">-- Server --</span>
<span class="c1">------------</span>
<span class="kd">function</span> <span class="nf">Server_Name</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the name of the server as set by AWS.Server.Start</span>
<span class="kd">function</span> <span class="nf">Protocol_Family</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Server protocol family. Family_Inet for IPv4, Family_Inet6 for IPv6 and</span>
<span class="c1">-- Family_Unspec for unspecified protocol family.</span>
<span class="kd">function</span> <span class="nf">Server_Host</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the server host. Can be used if the computer has a more than</span>
<span class="c1">-- one IP address. It is possible to have two servers at the same port</span>
<span class="c1">-- on the same machine, both being binded on different IP addresses.</span>
<span class="kd">function</span> <span class="nf">Server_Port</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the server port as set by the HTTP object declaration</span>
<span class="kd">function</span> <span class="nf">Hotplug_Port</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the hotplug communication port needed to register and</span>
<span class="c1">-- un-register an hotplug module.</span>
<span class="kd">function</span> <span class="nf">Session</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the server session is activated</span>
<span class="kd">function</span> <span class="nf">Case_Sensitive_Parameters</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- HTTP parameters are case sensitive</span>
<span class="kd">function</span> <span class="nf">Session_Name</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Name of the cookie session</span>
<span class="kd">function</span> <span class="nf">Server_Priority</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">System</span><span class="p">.</span><span class="n">Any_Priority</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the priority used by the HTTP and WebSockets servers</span>
<span class="c1">----------------</span>
<span class="c1">-- Connection --</span>
<span class="c1">----------------</span>
<span class="kd">function</span> <span class="nf">Max_Connection</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the max simultaneous connections as set by the HTTP object</span>
<span class="c1">-- declaration.</span>
<span class="kd">function</span> <span class="nf">Send_Buffer_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the socket buffer size used for sending data. Increasing this</span>
<span class="c1">-- value will give better performances on slow or long distances</span>
<span class="c1">-- connections.</span>
<span class="kd">function</span> <span class="nf">Free_Slots_Keep_Alive_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- The minimum number of free slots where keep-alive connections are still</span>
<span class="c1">-- enabled. After this limit no more keep-alive connection will be</span>
<span class="c1">-- accepted by the server. This parameter must be used for heavy-loaded</span>
<span class="c1">-- servers to make sure the server will never run out of slots. This limit</span>
<span class="c1">-- must be less than Max_Connection.</span>
<span class="kd">function</span> <span class="nf">Keep_Alive_Force_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Server could have more than Max_Connection keep-alive sockets. Keep</span>
<span class="c1">-- alive sockets are waiting for client input in the internal server socket</span>
<span class="c1">-- set. This parameter defines the maximum number of keep alive sockets</span>
<span class="c1">-- processed by the server with standard timeouts. If number of keep-alive</span>
<span class="c1">-- sockets becomes more than Keep_Alive_Force_Limit the server starts to</span>
<span class="c1">-- use shorter timeouts. If this parameter is not defined in the</span>
<span class="c1">-- configuration, the server uses Max_Connection * 2 as value.</span>
<span class="kd">function</span> <span class="nf">Keep_Alive_Close_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This parameter defines the limit of keep alive sockets in the internal</span>
<span class="c1">-- server socket set. If the number of sockets in socket set became more</span>
<span class="c1">-- than Keep_Alive_Close_Limit, most close to timeout socket would be</span>
<span class="c1">-- closed. If this parameter is not defined in the configuration,</span>
<span class="c1">-- the server uses Max_Connection * 4 as value.</span>
<span class="kd">function</span> <span class="nf">Accept_Queue_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the size of the queue for the incoming requests. Higher this</span>
<span class="c1">-- value will be and less "connection refused" will be reported to the</span>
<span class="c1">-- client.</span>
<span class="kd">function</span> <span class="nf">Line_Stack_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- HTTP lines stack size</span>
<span class="kd">function</span> <span class="nf">Reuse_Address</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns true if bind is allowed to reuse and address (not waiting for</span>
<span class="c1">-- the delay between two bind to the same port).</span>
<span class="c1">----------</span>
<span class="c1">-- Data --</span>
<span class="c1">----------</span>
<span class="kd">function</span> <span class="nf">WWW_Root</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the root directory name for the server. This variable is not</span>
<span class="c1">-- used internally by AWS. It is supposed to be used by the callback</span>
<span class="c1">-- procedures who want to retrieve physical objects (images, Web pages...).</span>
<span class="c1">-- The default value is the current working directory. The returned</span>
<span class="c1">-- directory ends with a directory separator.</span>
<span class="kd">function</span> <span class="nf">Upload_Directory</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This point to the directory where uploaded files will be stored. The</span>
<span class="c1">-- directory returned will end with a directory separator.</span>
<span class="kd">function</span> <span class="nf">Upload_Size_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Directory_Browser_Page</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Filename for the directory browser template page</span>
<span class="kd">function</span> <span class="nf">Max_POST_Parameters</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the maximum number of POST parameters handled. Past this limit</span>
<span class="c1">-- the exception Too_Many_Parameters is raised.</span>
<span class="c1">---------</span>
<span class="c1">-- Log --</span>
<span class="c1">---------</span>
<span class="kd">function</span> <span class="nf">Log_File_Directory</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This point to the directory where log files will be written. The</span>
<span class="c1">-- directory returned will end with a directory separator.</span>
<span class="kd">function</span> <span class="nf">Log_Filename_Prefix</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the prefix to use for the log filename</span>
<span class="kd">function</span> <span class="nf">Log_Split_Mode</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is split mode for the log file. Possible values are : Each_Run,</span>
<span class="c1">-- Daily, Monthly and None. Any other values will raise an exception.</span>
<span class="kd">function</span> <span class="nf">Log_Size_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Field_Id</span> <span class="p">(</span><span class="n">Id</span> <span class="p">:</span> <span class="kt">String</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Log_Extended_Fields_Generic_Iterate</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Calls procedure Field_Id for each extended http log field identifier</span>
<span class="kd">function</span> <span class="nf">Log_Extended_Fields_Length</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the number of extended http log fileds identifiers.</span>
<span class="c1">-- If returned value is zero then http log is not extended.</span>
<span class="kd">function</span> <span class="nf">Error_Log_Filename_Prefix</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the prefix to use for the log filename</span>
<span class="kd">function</span> <span class="nf">Error_Log_Split_Mode</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is split mode for the log file. Possible values are : Each_Run,</span>
<span class="c1">-- Daily, Monthly and None. Any other values will raise an exception.</span>
<span class="c1">------------</span>
<span class="c1">-- Status --</span>
<span class="c1">------------</span>
<span class="kd">function</span> <span class="nf">Admin_Password</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- The admin password</span>
<span class="kd">function</span> <span class="nf">Admin_Realm</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- The admin password</span>
<span class="kd">function</span> <span class="nf">Admin_URI</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- This is the name of the admin server page as set by AWS.Server.Start.</span>
<span class="c1">-- It is also known as the status page.</span>
<span class="kd">function</span> <span class="nf">Status_Page</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Filename for the status template page</span>
<span class="kd">function</span> <span class="nf">Up_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Filename for the up arrow image used in the status page</span>
<span class="kd">function</span> <span class="nf">Down_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Filename for the down arrow image used in the status page</span>
<span class="kd">function</span> <span class="nf">Logo_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Filename for the AWS logo image used in the status page</span>
<span class="c1">--------------</span>
<span class="c1">-- Timeouts --</span>
<span class="c1">--------------</span>
<span class="kd">function</span> <span class="nf">Cleaner_Wait_For_Client_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for a client request.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">function</span> <span class="nf">Cleaner_Client_Header_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for client header.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">function</span> <span class="nf">Cleaner_Client_Data_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for client message body.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">function</span> <span class="nf">Cleaner_Server_Response_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for client to accept answer.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">function</span> <span class="nf">Force_Wait_For_Client_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for a client request.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">function</span> <span class="nf">Force_Client_Header_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for client header.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">function</span> <span class="nf">Force_Client_Data_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for client message body.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">function</span> <span class="nf">Force_Server_Response_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timout on waiting for client to accept answer.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">function</span> <span class="nf">Send_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timeout when sending chunck of data</span>
<span class="kd">function</span> <span class="nf">Receive_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Duration</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to timeout when receiving chunck of data</span>
<span class="c1">--------------</span>
<span class="c1">-- Security --</span>
<span class="c1">--------------</span>
<span class="kd">function</span> <span class="nf">Check_URL_Validity</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Server have to check URI for validity. For example it checks that an</span>
<span class="c1">-- URL does not reference a resource above the Web root.</span>
<span class="kd">function</span> <span class="nf">Security</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Is the server working through th SSL</span>
<span class="kd">function</span> <span class="nf">Certificate</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the certificate to be used with the secure server. Returns the</span>
<span class="c1">-- empty string if the server is not a secure one.</span>
<span class="kd">function</span> <span class="nf">Key</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the key to be used with the secure server. Returns the</span>
<span class="c1">-- empty string if the server is not a secure one.</span>
<span class="kd">function</span> <span class="nf">Security_Mode</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the security mode to be used with the secure server. Returns the</span>
<span class="c1">-- empty string if the server is not a secure one.</span>
<span class="kd">function</span> <span class="nf">Cipher_Priorities</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the cipher priorities for the security communication</span>
<span class="kd">function</span> <span class="nf">TLS_Ticket_Support</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Is security communication side has support stateless TLS session</span>
<span class="c1">-- resumption. See RFC 5077.</span>
<span class="kd">function</span> <span class="nf">Exchange_Certificate</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the client is requested to send its certificate to the</span>
<span class="c1">-- server.</span>
<span class="kd">function</span> <span class="nf">Certificate_Required</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the server must abort the connection if the</span>
<span class="c1">-- client did not provide trusted certificate. If this option is set</span>
<span class="c1">-- the Exchange_Certificate must also be set.</span>
<span class="kd">function</span> <span class="nf">Trusted_CA</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the filename containing a list of trusted CA, this is to be used</span>
<span class="c1">-- with the Exchange_Certificate option. The filename is on bundle of CAs</span>
<span class="c1">-- that can be trusted. A client certificate signed with one of those CA</span>
<span class="c1">-- will be accetped by the server.</span>
<span class="kd">function</span> <span class="nf">CRL_File</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the filename containing the Certificate Revocation List. This</span>
<span class="c1">-- list is used by the server to check for revoked certificate.</span>
<span class="kd">function</span> <span class="nf">SSL_Session_Cache_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns SSL session cashe size</span>
<span class="c1">-------------------------</span>
<span class="c1">-- Per Process options --</span>
<span class="c1">-------------------------</span>
<span class="kd">function</span> <span class="nf">Session_Cleanup_Interval</span> <span class="nf">return</span> <span class="nf">Duration</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds between each run of the cleaner task to remove</span>
<span class="c1">-- obsolete session data.</span>
<span class="kd">function</span> <span class="nf">Session_Lifetime</span> <span class="nf">return</span> <span class="nf">Duration</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to keep a session if not used. After this period the</span>
<span class="c1">-- session data is obsoleted and will be removed during next cleanup.</span>
<span class="kd">function</span> <span class="nf">Session_Id_Length</span> <span class="nf">return</span> <span class="nf">Positive</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the length (number of characters) of the session id</span>
<span class="kd">function</span> <span class="nf">Session_Cleaner_Priority</span> <span class="nf">return</span> <span class="nf">System</span><span class="p">.</span><span class="nf">Any_Priority</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the priority used by the session cleaner task</span>
<span class="kd">function</span> <span class="nf">Service_Priority</span> <span class="nf">return</span> <span class="nf">System</span><span class="p">.</span><span class="nf">Any_Priority</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the priority used by the others services (SMTP server, Jabber</span>
<span class="c1">-- server, Push server...).</span>
<span class="kd">function</span> <span class="nf">Config_Directory</span> <span class="nf">return</span> <span class="nf">String</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Directory where AWS parameter files are located</span>
<span class="kd">function</span> <span class="nf">Transient_Cleanup_Interval</span> <span class="nf">return</span> <span class="nf">Duration</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds between each run of the cleaner task to remove</span>
<span class="c1">-- transient pages.</span>
<span class="kd">function</span> <span class="nf">Transient_Lifetime</span> <span class="nf">return</span> <span class="nf">Duration</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to keep a transient page. After this period the</span>
<span class="c1">-- transient page is obsoleted and will be removed during next cleanup.</span>
<span class="kd">function</span> <span class="nf">Max_Concurrent_Download</span> <span class="nf">return</span> <span class="nf">Positive</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Number of maximum concurrent download supported by the download manager</span>
<span class="c1">-- service.</span>
<span class="kd">function</span> <span class="nf">MIME_Types</span> <span class="nf">return</span> <span class="nf">String</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the file name of the MIME types to use</span>
<span class="kd">function</span> <span class="nf">Input_Line_Size_Limit</span> <span class="nf">return</span> <span class="nf">Positive</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Limit of the HTTP protocol text lines length</span>
<span class="kd">function</span> <span class="nf">Context_Lifetime</span> <span class="nf">return</span> <span class="nf">Duration</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Number of seconds to keep a context if not used. After this period the</span>
<span class="c1">-- context data is obsoleted and will be removed during next cleanup.</span>
<span class="kd">function</span> <span class="nf">Max_WebSocket_Handler</span> <span class="nf">return</span> <span class="nf">Positive</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- This is the max simultaneous connections handling WebSocket's messages</span>
<span class="kd">function</span> <span class="nf">WebSocket_Message_Queue_Size</span> <span class="nf">return</span> <span class="nf">Positive</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- This is the size of the queue containing incoming messages</span>
<span class="kd">function</span> <span class="nf">Max_WebSocket</span> <span class="nf">return</span> <span class="nf">Positive</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- The maximum number of simultaneous WebSocket opened. Note that that</span>
<span class="c1">-- there could be more WebSocket registered when counting the closing</span>
<span class="c1">-- WebSockets.</span>
<span class="kd">function</span> <span class="nf">WebSocket_Timeout</span> <span class="nf">return</span> <span class="nf">Duration</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the WebSocket activity timeout. After this number of seconds</span>
<span class="c1">-- without any activity the WebSocket can be closed when needed.</span>
<span class="kd">function</span> <span class="nf">Is_WebSocket_Origin_Set</span> <span class="nf">return</span> <span class="nf">Boolean</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the Origin has been set</span>
<span class="kd">function</span> <span class="nf">WebSocket_Origin</span> <span class="nf">return</span> <span class="nf">GNAT</span><span class="p">.</span><span class="nf">Regexp</span><span class="p">.</span><span class="nf">Regexp</span><span class="p">;</span>
<span class="c1">-- This is regular expression to restrict WebSocket to a specific origin</span>
<span class="kd">function</span> <span class="nf">WebSocket_Origin</span> <span class="nf">return</span> <span class="nf">String</span><span class="p">;</span>
<span class="c1">-- This is the string regular expression to restrict WebSocket to a</span>
<span class="c1">-- specific origin.</span>
<span class="kd">function</span> <span class="nf">WebSocket_Priority</span> <span class="nf">return</span> <span class="nf">System</span><span class="p">.</span><span class="nf">Any_Priority</span><span class="p">;</span>
<span class="c1">-- Set the priority used by the WebSocket service</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Config</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-config-ini">
<span id="id9"></span><h2>13.9. AWS.Config.Ini<a class="headerlink" href="#aws-config-ini" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-7"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Handle .ini style configuration files. In those files each option is on one</span>
<span class="c1">-- line. The first word is the option name and the second one is the option</span>
<span class="c1">-- value.</span>
<span class="kd">package</span> <span class="nc">AWS.Config.Ini</span> <span class="kr">is</span>
<span class="kd">function</span> <span class="nf">Program_Ini_File</span> <span class="p">(</span><span class="nv">Full_Path</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns initialization filename for current server (using the</span>
<span class="c1">-- executable name and adding .ini).</span>
<span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Config</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Read Filename and update the configuration object with the</span>
<span class="c1">-- options read from it. Raises Ada.Text_IO.Name_Error if Filename does</span>
<span class="c1">-- not exist. Raises Constraint_Error in case of wrong any parameter name</span>
<span class="c1">-- or value.</span>
<span class="kr">end</span> <span class="nf">AWS.Config.Ini</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-config-set">
<span id="id10"></span><h2>13.10. AWS.Config.Set<a class="headerlink" href="#aws-config-set" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-8"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- This package can be used to Set any AWS parameters</span>
<span class="kd">package</span> <span class="nc">AWS.Config.Set</span> <span class="kr">is</span>
<span class="c1">------------------------</span>
<span class="c1">-- Per Server Options --</span>
<span class="c1">------------------------</span>
<span class="c1">------------</span>
<span class="c1">-- Server --</span>
<span class="c1">------------</span>
<span class="kd">procedure</span> <span class="nf">Server_Name</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the name of the server as set by AWS.Server.Start</span>
<span class="kd">procedure</span> <span class="nf">Protocol_Family</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the server protocol family. Family_Inet for IPv4, Family_Inet6 for</span>
<span class="c1">-- IPv6 and Family_Unspec for unspecified protocol family.</span>
<span class="kd">procedure</span> <span class="nf">Server_Host</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the server host as set by the HTTP object declaration</span>
<span class="kd">procedure</span> <span class="nf">Server_Port</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-- This is the server port as set by the HTTP object declaration</span>
<span class="kd">procedure</span> <span class="nf">Hotplug_Port</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- This is the hotplug communication port needed to register and</span>
<span class="c1">-- un-register an hotplug module.</span>
<span class="kd">procedure</span> <span class="nf">Session</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Enable session handling is Value is True</span>
<span class="kd">procedure</span> <span class="nf">Case_Sensitive_Parameters</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Parameters are handled with the case if Value is True</span>
<span class="kd">procedure</span> <span class="nf">Line_Stack_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- HTTP lines stack size</span>
<span class="kd">procedure</span> <span class="nf">Reuse_Address</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Set the reuse address policy allowing a bind without a dealy to the same</span>
<span class="c1">-- address and port.</span>
<span class="kd">procedure</span> <span class="nf">Session_Name</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Name of the cookie session</span>
<span class="kd">procedure</span> <span class="nf">Server_Priority</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">System</span><span class="p">.</span><span class="nv">Any_Priority</span><span class="p">);</span>
<span class="c1">-- Set the priority used by the HTTP and WebSockets servers</span>
<span class="c1">----------------</span>
<span class="c1">-- Connection --</span>
<span class="c1">----------------</span>
<span class="kd">procedure</span> <span class="nf">Max_Connection</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- This is the max simultaneous connections as set by the HTTP object</span>
<span class="c1">-- declaration.</span>
<span class="kd">procedure</span> <span class="nf">Send_Buffer_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- This is the socket buffer size used for sending data. Increasing this</span>
<span class="c1">-- value will give better performances on slow or long distances</span>
<span class="c1">-- connections.</span>
<span class="kd">procedure</span> <span class="nf">Free_Slots_Keep_Alive_Limit</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-- The minimum number of free slots where keep-alive connections are still</span>
<span class="c1">-- enabled. After this limit no more keep-alive connection will be</span>
<span class="c1">-- accepted by the server. This parameter must be used for heavy-loaded</span>
<span class="c1">-- servers to make sure the server will never run out of slots. This limit</span>
<span class="c1">-- must be less than Max_Connection.</span>
<span class="kd">procedure</span> <span class="nf">Keep_Alive_Force_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-- Define maximum number of keep alive sockets where server process it with</span>
<span class="c1">-- normal timeouts. If number of keep-alive sockets become more than</span>
<span class="c1">-- Keep_Alive_Force_Limit, server start to use shorter force timeouts.</span>
<span class="c1">-- If this parameter not defined in configuration or defined as 0 value</span>
<span class="c1">-- server use calculated value Max_Connection * 2.</span>
<span class="kd">procedure</span> <span class="nf">Accept_Queue_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- This is the size of the queue for the incoming requests. Higher this</span>
<span class="c1">-- value will be and less "connection refused" will be reported to the</span>
<span class="c1">-- client.</span>
<span class="c1">----------</span>
<span class="c1">-- Data --</span>
<span class="c1">----------</span>
<span class="kd">procedure</span> <span class="nf">WWW_Root</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the root directory name for the server. This variable is not</span>
<span class="c1">-- used internally by AWS. It is supposed to be used by the callback</span>
<span class="c1">-- procedures who want to retrieve physical objects (images, Web</span>
<span class="c1">-- pages...). The default value is the current working directory.</span>
<span class="kd">procedure</span> <span class="nf">Upload_Directory</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This point to the directory where uploaded files will be stored. The</span>
<span class="c1">-- directory returned will end with a directory separator.</span>
<span class="kd">procedure</span> <span class="nf">Upload_Size_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- Set the maximum size accepted for uploaded files</span>
<span class="kd">procedure</span> <span class="nf">Directory_Browser_Page</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Filename for the directory browser template page</span>
<span class="kd">procedure</span> <span class="nf">Max_POST_Parameters</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- Set the maximum number of POST parameters handled. Past this limit</span>
<span class="c1">-- the exception Too_Many_Parameters is raised.</span>
<span class="c1">---------</span>
<span class="c1">-- Log --</span>
<span class="c1">---------</span>
<span class="kd">procedure</span> <span class="nf">Log_File_Directory</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This point to the directory where log files will be written. The</span>
<span class="c1">-- directory returned will end with a directory separator.</span>
<span class="kd">procedure</span> <span class="nf">Log_Filename_Prefix</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the prefix to use for the log filename</span>
<span class="kd">procedure</span> <span class="nf">Log_Size_Limit</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-- If Log_Size_Limit is more than zero and size of log file</span>
<span class="c1">-- become more than Log_Size_Limit, log file is be split.</span>
<span class="kd">procedure</span> <span class="nf">Log_Split_Mode</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is split mode for the log file. Possible values are : Each_Run,</span>
<span class="c1">-- Daily, Monthly and None. Any other values will raise an exception.</span>
<span class="kd">procedure</span> <span class="nf">Log_Extended_Fields</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Comma separated list of the extended log field names. If this parameter</span>
<span class="c1">-- is empty, the HTTP log would have fixed apache compartible format:</span>
<span class="c1">--</span>
<span class="c1">-- 127.0.0.1 - - [25/Apr/1998:15:37:29 +0200] "GET / HTTP/1.0" 200 1363</span>
<span class="c1">--</span>
<span class="c1">-- If the extended fields list is not empty, the log file format would have</span>
<span class="c1">-- user defined fields set:</span>
<span class="c1">--</span>
<span class="c1">-- #Version: 1.0</span>
<span class="c1">-- #Date: 2006-01-09 00:00:01</span>
<span class="c1">-- #Fields: date time cs-method cs-uri cs-version sc-status sc-bytes</span>
<span class="c1">-- 2006-01-09 00:34:23 GET /foo/bar.html HTTP/1.1 200 30</span>
<span class="c1">--</span>
<span class="c1">-- Fields in the list could be:</span>
<span class="c1">--</span>
<span class="c1">-- date Date at which transaction completed</span>
<span class="c1">-- time Time at which transaction completed</span>
<span class="c1">-- c-ip Client side connected IP address</span>
<span class="c1">-- c-port Client side connected port</span>
<span class="c1">-- s-ip Server side connected IP address</span>
<span class="c1">-- s-port Server side connected port</span>
<span class="c1">-- cs-method HTTP request method</span>
<span class="c1">-- cs-username Client authentication username</span>
<span class="c1">-- cs-version Client supported HTTP version</span>
<span class="c1">-- cs-uri Request URI</span>
<span class="c1">-- cs-uri-stem Stem portion alone of URI (omitting query)</span>
<span class="c1">-- cs-uri-query Query portion alone of URI</span>
<span class="c1">-- sc-status Responce status code</span>
<span class="c1">-- sc-bytes Length of response message body</span>
<span class="c1">-- cs(<header>) Any header field name sent from client to server</span>
<span class="c1">-- sc(<header>) Any header field name sent from server to client</span>
<span class="c1">-- x-<appfield> Any application defined field name</span>
<span class="kd">procedure</span> <span class="nf">Error_Log_Filename_Prefix</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the prefix to use for the log filename</span>
<span class="kd">procedure</span> <span class="nf">Error_Log_Split_Mode</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is split mode for the log file. Possible values are : Each_Run,</span>
<span class="c1">-- Daily, Monthly and None. Any other values will raise an exception.</span>
<span class="c1">------------</span>
<span class="c1">-- Status --</span>
<span class="c1">------------</span>
<span class="kd">procedure</span> <span class="nf">Admin_Password</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the password for the admin server page as set by</span>
<span class="c1">-- AWS.Server.Start. The password must be created with the aws_password</span>
<span class="c1">-- tool.</span>
<span class="kd">procedure</span> <span class="nf">Admin_URI</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is the name of the admin server page as set by AWS.Server.Start</span>
<span class="kd">procedure</span> <span class="nf">Status_Page</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Filename for the status template page</span>
<span class="kd">procedure</span> <span class="nf">Up_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Filename for the up arrow image used in the status page</span>
<span class="kd">procedure</span> <span class="nf">Down_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Filename for the down arrow image used in the status page</span>
<span class="kd">procedure</span> <span class="nf">Logo_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Filename for the AWS logo image used in the status page</span>
<span class="c1">--------------</span>
<span class="c1">-- Timeouts --</span>
<span class="c1">--------------</span>
<span class="kd">procedure</span> <span class="nf">Cleaner_Wait_For_Client_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for a client request.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">procedure</span> <span class="nf">Cleaner_Client_Header_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for client header.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">procedure</span> <span class="nf">Cleaner_Client_Data_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for client message body.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">procedure</span> <span class="nf">Cleaner_Server_Response_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for client to accept answer.</span>
<span class="c1">-- This is a timeout for regular cleaning task.</span>
<span class="kd">procedure</span> <span class="nf">Force_Wait_For_Client_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for a client request.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">procedure</span> <span class="nf">Force_Client_Header_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for client header.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">procedure</span> <span class="nf">Force_Client_Data_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for client message body.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">procedure</span> <span class="nf">Force_Server_Response_Timeout</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timout on waiting for client to accept answer.</span>
<span class="c1">-- This is a timeout for urgent request when resources are missing.</span>
<span class="kd">procedure</span> <span class="nf">Send_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timeout when sending chunck of data</span>
<span class="kd">procedure</span> <span class="nf">Receive_Timeout</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to timeout when receiving chunck of data</span>
<span class="c1">--------------</span>
<span class="c1">-- Security --</span>
<span class="c1">--------------</span>
<span class="kd">procedure</span> <span class="nf">Check_URL_Validity</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Set the check URL validity flag. If True an URL that reference a</span>
<span class="c1">-- resource above the Web root will be rejected.</span>
<span class="kd">procedure</span> <span class="nf">Security</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Enable security (HTTPS/SSL) if Value is True</span>
<span class="kd">procedure</span> <span class="nf">Certificate</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the certificate to be used with the secure server</span>
<span class="kd">procedure</span> <span class="nf">Key</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the key to be used with the secure server</span>
<span class="kd">procedure</span> <span class="nf">Security_Mode</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Mode</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the security mode to be used with the secure server. Only values</span>
<span class="c1">-- from AWS.Net.SSL.Method can be used.</span>
<span class="kd">procedure</span> <span class="nf">Cipher_Priorities</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Sets priorities for the cipher suites supported by SSL implementation.</span>
<span class="c1">-- GNUTLS and OpenSSL implementations has different sintax for this</span>
<span class="c1">-- parameter.</span>
<span class="kd">procedure</span> <span class="nf">TLS_Ticket_Support</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Set to True for security communication side support stateless TLS</span>
<span class="c1">-- session resumption. See RFC 5077.</span>
<span class="kd">procedure</span> <span class="nf">Exchange_Certificate</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Set to True to request the client to send its certificate to the server</span>
<span class="kd">procedure</span> <span class="nf">Certificate_Required</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Returns True if the server must abort the connection if the</span>
<span class="c1">-- client did not provide a certificate. If this option is set</span>
<span class="c1">-- the Exchange_Certificate must also be set.</span>
<span class="kd">procedure</span> <span class="nf">Trusted_CA</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Returns the filename containing a list of trusted CA, this is to be used</span>
<span class="c1">-- with the Exchange_Certificate option. The filename is on bundle of CAs</span>
<span class="c1">-- that can be trusted. A client certificate signed with one of those CA</span>
<span class="c1">-- will be accetped by the server.</span>
<span class="kd">procedure</span> <span class="nf">CRL_File</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Returns the filename containing the Certificate Revocation List. This</span>
<span class="c1">-- list is used by the server to check for revoked certificate.</span>
<span class="kd">procedure</span> <span class="nf">SSL_Session_Cache_Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-------------------------</span>
<span class="c1">-- Per Process Options --</span>
<span class="c1">-------------------------</span>
<span class="kd">procedure</span> <span class="nf">Session_Cleanup_Interval</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds between each run of the cleaner task to remove</span>
<span class="c1">-- obsolete session data.</span>
<span class="kd">procedure</span> <span class="nf">Session_Lifetime</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to keep a session if not used. After this period the</span>
<span class="c1">-- session data is obsoleted and will be removed during next cleanup.</span>
<span class="kd">procedure</span> <span class="nf">Session_Id_Length</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- Returns the length (number of characters) of the session id</span>
<span class="kd">procedure</span> <span class="nf">Session_Cleaner_Priority</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">System</span><span class="p">.</span><span class="nv">Any_Priority</span><span class="p">);</span>
<span class="c1">-- Set the priority used by the session cleaner task</span>
<span class="kd">procedure</span> <span class="nf">Service_Priority</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">System</span><span class="p">.</span><span class="nv">Any_Priority</span><span class="p">);</span>
<span class="c1">-- Set the priority used by the others services (SMTP server, Jabber</span>
<span class="c1">-- server, Push server...).</span>
<span class="kd">procedure</span> <span class="nf">Config_Directory</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Directory where AWS parameter files are located</span>
<span class="kd">procedure</span> <span class="nf">Transient_Cleanup_Interval</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds between each run of the cleaner task to remove</span>
<span class="c1">-- transient pages.</span>
<span class="kd">procedure</span> <span class="nf">Transient_Lifetime</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to keep a transient page. After this period the</span>
<span class="c1">-- transient page is obsoleted and will be removed during next cleanup.</span>
<span class="kd">procedure</span> <span class="nf">Context_Lifetime</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Number of seconds to keep a context if not used. After this period the</span>
<span class="c1">-- context data is obsoleted and will be removed during next cleanup.</span>
<span class="kd">procedure</span> <span class="nf">Max_Concurrent_Download</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- Control the maximum number of parallel downloads accepted by the</span>
<span class="c1">-- download manager.</span>
<span class="kd">procedure</span> <span class="nf">Max_WebSocket</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- The maximum number of simultaneous WebSocket opened. Note that that</span>
<span class="c1">-- there could be more WebSocket registered when counting the closing</span>
<span class="c1">-- WebSockets.</span>
<span class="kd">procedure</span> <span class="nf">Max_WebSocket_Handler</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- This is the max simultaneous connections handling WebSocket's messages</span>
<span class="kd">procedure</span> <span class="nf">MIME_Types</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- The name of the file containing the MIME types associations</span>
<span class="kd">procedure</span> <span class="nf">WebSocket_Message_Queue_Size</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- This is the size of the queue containing incoming messages</span>
<span class="kd">procedure</span> <span class="nf">WebSocket_Origin</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- This is regular expression to restrict WebSocket to a specific origin</span>
<span class="kd">procedure</span> <span class="nf">WebSocket_Priority</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">System</span><span class="p">.</span><span class="nv">Any_Priority</span><span class="p">);</span>
<span class="c1">-- Set the priority used by the WebSocket service</span>
<span class="kd">procedure</span> <span class="nf">WebSocket_Timeout</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Returns the WebSocket activity timeout. After this number of seconds</span>
<span class="c1">-- without any activity the WebSocket can be closed when needed.</span>
<span class="kd">procedure</span> <span class="nf">Input_Line_Size_Limit</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- Maximum length of an HTTP parameter</span>
<span class="kd">procedure</span> <span class="nf">Parameter</span>
<span class="p">(</span><span class="nv">Config</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Error_Context</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Set one of the AWS HTTP per server parameters. Raises Constraint_Error</span>
<span class="c1">-- in case of wrong parameter name or wrong parameter value.</span>
<span class="c1">-- Error_Context may contain additional information about the parameter.</span>
<span class="c1">-- This message will be added to the Constraint_Error exception.</span>
<span class="c1">-- One way to use Error_Context is to set it with information about</span>
<span class="c1">-- where this parameter come form.</span>
<span class="kd">procedure</span> <span class="nf">Parameter</span>
<span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Error_Context</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Set one of the AWS HTTP per process parameters. See description above</span>
<span class="kr">end</span> <span class="nf">AWS.Config.Set</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-containers-tables">
<span id="id11"></span><h2>13.11. AWS.Containers.Tables<a class="headerlink" href="#aws-containers-tables" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-9"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2017, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Ordered_Maps</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Vectors</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Vectors</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Containers.Tables</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Table_Type</span> <span class="kr">is</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="no">Empty_Table</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Table_Type</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Element</span> <span class="p">(</span><span class="nv">Name_Length</span><span class="p">,</span> <span class="nv">Value_Length</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">Name</span> <span class="p">:</span> <span class="kt">String</span> <span class="p">(</span><span class="mi">1</span> <span class="p">..</span> <span class="n">Name_Length</span><span class="p">);</span>
<span class="n">Value</span> <span class="p">:</span> <span class="kt">String</span> <span class="p">(</span><span class="mi">1</span> <span class="p">..</span> <span class="n">Value_Length</span><span class="p">);</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="c1">-- Data type to store name/value pair retrieved from a Table_Type</span>
<span class="no">Null_Element</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Element</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">VString_Array</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Count</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of items in Table</span>
<span class="kd">function</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns true if table is empty</span>
<span class="kd">function</span> <span class="nf">Name_Count</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of unique key name in Table</span>
<span class="kd">function</span> <span class="nf">Case_Sensitive</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns case sensitivity flag of the Table</span>
<span class="kd">function</span> <span class="nf">Count</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of value for Key Name in Table. It returns</span>
<span class="c1">-- 0 if Key does not exist.</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if Key exist in Table</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="p">(</span><span class="kr">if</span> <span class="n">N</span> <span class="o">></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span> <span class="kr">then</span> <span class="n">Get</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">);</span>
<span class="c1">-- Returns the Nth value associated with Key into Table. Returns</span>
<span class="c1">-- the emptry string if key does not exist.</span>
<span class="kd">function</span> <span class="nf">Get_Name</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="p">(</span><span class="kr">if</span> <span class="n">N</span> <span class="o">></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">)</span> <span class="kr">then</span> <span class="n">Get_Name</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">);</span>
<span class="c1">-- Returns the Nth Name in Table or the empty string if there is</span>
<span class="c1">-- no parameter with this number.</span>
<span class="kd">function</span> <span class="nf">Get_Value</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="p">(</span><span class="kr">if</span> <span class="n">N</span> <span class="o">></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">)</span> <span class="kr">then</span> <span class="n">Get_Value</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">);</span>
<span class="c1">-- Returns the Nth Value in Table or the empty string if there is</span>
<span class="c1">-- no parameter with this number.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Element</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="p">(</span><span class="kr">if</span> <span class="n">N</span> <span class="o">></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">)</span> <span class="kr">then</span> <span class="n">Get</span><span class="p">'</span><span class="na">Result</span> <span class="o">=</span> <span class="n">Null_Element</span><span class="p">);</span>
<span class="c1">-- Returns N'th name/value pair. Returns Null_Element if there is no</span>
<span class="c1">-- such item in the table.</span>
<span class="kd">function</span> <span class="nf">Get_Names</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">VString_Array</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Get_Names</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="n">Name_Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">);</span>
<span class="c1">-- Returns sorted array of unique key names</span>
<span class="kd">function</span> <span class="nf">Get_Values</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">VString_Array</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Get_Values</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">,</span> <span class="n">Name</span><span class="p">);</span>
<span class="c1">-- Returns all values for the specified parameter key name</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Process</span> <span class="p">(</span><span class="n">Name</span><span class="p">,</span> <span class="n">Value</span> <span class="p">:</span> <span class="kt">String</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Generic_Iterate_Names</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span> <span class="nv">Separator</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Iterates over all names in the table.</span>
<span class="c1">-- All Values of the same name are separated by Separator string.</span>
<span class="kd">procedure</span> <span class="nf">Iterate_Names</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Separator</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Process</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">procedure</span> <span class="p">(</span><span class="nv">Name</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">));</span>
<span class="kd">function</span> <span class="nf">Union</span>
<span class="p">(</span><span class="nv">Left</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Right</span> <span class="p">: </span><span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Unique</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Table_Type</span><span class="p">;</span>
<span class="c1">-- Concatenates two tables, If Unique is True do not add Right container</span>
<span class="c1">-- element into result when element with the same name already exists in</span>
<span class="c1">-- the Left container.</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Name</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">)</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">'</span><span class="na">Old</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>
<span class="ow">or else</span>
<span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">'</span><span class="na">Old</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">-- Add a new Key/Value pair into Table. A new value is always added,</span>
<span class="c1">-- even if there is already an entry with the same name.</span>
<span class="kd">procedure</span> <span class="nf">Update</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span>
<span class="kn">with</span>
<span class="nn">Pre</span> <span class="p">=></span>
<span class="c1">-- Count + 1 means it is added at the end of the table</span>
<span class="n">N</span> <span class="o"><=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
<span class="n">Post</span> <span class="p">=></span>
<span class="c1">-- Value already exists, it is updated</span>
<span class="p">(</span><span class="n">N</span> <span class="o"><=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">'</span><span class="na">Old</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span>
<span class="ow">and then</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">'</span><span class="na">Old</span><span class="p">,</span> <span class="n">Name</span><span class="p">))</span>
<span class="c1">-- New value appended</span>
<span class="ow">or else</span>
<span class="p">(</span><span class="n">N</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">'</span><span class="na">Old</span><span class="p">,</span> <span class="n">Name</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>
<span class="ow">and then</span> <span class="n">N</span> <span class="o">=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">,</span> <span class="n">Name</span><span class="p">));</span>
<span class="c1">-- Update the N-th Value with the given Name into the Table.</span>
<span class="c1">-- The container could already have more than one value associated with</span>
<span class="c1">-- this name.</span>
<span class="kd">procedure</span> <span class="nf">Case_Sensitive</span>
<span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Table_Type</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- If Mode is True it will use all parameters with case sensitivity</span>
<span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Table</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Table_Type</span><span class="p">)</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Table</span><span class="p">)</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Removes all object from Table. Table will be reinitialized and will be</span>
<span class="c1">-- ready for new use.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Containers.Tables</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-cookie">
<span id="id12"></span><h2>13.12. AWS.Cookie<a class="headerlink" href="#aws-cookie" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-10"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2010-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- A package for basic HTTP state management, ie. cookies. Tokens and</span>
<span class="c1">-- attributes adhere to RFC-2109: http://tools.ietf.org/html/rfc2109</span>
<span class="kn">with</span> <span class="nn">AWS.Default</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Cookie</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">type</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Data_Mode</span><span class="p">;</span>
<span class="n">Response_Data_Not_Initialized</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- The Response_Data_Not_Initialized exception is raised when trying to add</span>
<span class="c1">-- headers to an un-initialized AWS.Response.Data object.</span>
<span class="c1">-- The AWS.Response.Data object is initialized using the</span>
<span class="c1">-- AWS.Response.Build function.</span>
<span class="no">No_Max_Age</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">Duration</span><span class="p">;</span>
<span class="c1">-- When no Max-Age is required, this value can be passed to the Set</span>
<span class="c1">-- routines below.</span>
<span class="kd">function</span> <span class="nf">Exists</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Check if the 'Key' cookie exists in AWS.Headers.List. Return Boolean</span>
<span class="c1">-- True of the cookie exists, else Boolean False.</span>
<span class="kd">procedure</span> <span class="nf">Expire</span>
<span class="p">(</span><span class="nv">Content</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Path</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"/"</span><span class="p">);</span>
<span class="c1">-- Expire the 'Key' cookie. This is done by setting the Max-Age attribute</span>
<span class="c1">-- to 0. The Value of the cookie is also set to "", in case a browser does</span>
<span class="c1">-- not honor the Max-Age attribute.</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Return the 'Key' cookie from AWS.Headers.List. If the cookie does not</span>
<span class="c1">-- exist, return an empty string, ie. ""</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span><span class="p">;</span>
<span class="c1">-- Return the 'Key' cookie from AWS.Headers.List. If the cookie does not</span>
<span class="c1">-- exist or can't be converted from String to Integer then return 0.</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Float</span><span class="p">;</span>
<span class="c1">-- Return the 'Key' cookie from AWS.Headers.List. If the cookie does not</span>
<span class="c1">-- exist or can't be converted from String to Float then return 0.0.</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Return the 'Key' cookie from AWS.Headers.List. Only if the cookie value</span>
<span class="c1">-- equals "True" is Boolean True returned, else Boolean False is returned.</span>
<span class="kd">procedure</span> <span class="nf">Set</span>
<span class="p">(</span><span class="nv">Content</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Comment</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Domain</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Max_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Ten_Years</span><span class="p">;</span>
<span class="nv">Path</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"/"</span><span class="p">;</span>
<span class="nv">Secure</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Response</span><span class="p">.</span><span class="n">Mode</span> <span class="p">(</span><span class="n">Content</span><span class="p">)</span> <span class="o">/=</span> <span class="n">Response</span><span class="p">.</span><span class="n">No_Data</span><span class="p">;</span>
<span class="c1">-- Set a new cookie named 'Key' with value 'Value'. See RFC 2109 for more</span>
<span class="c1">-- information about the individual cookie attributes:</span>
<span class="c1">-- http://tools.ietf.org/html/rfc2109</span>
<span class="c1">--</span>
<span class="c1">-- Exceptions:</span>
<span class="c1">-- Response_Data_Not_Initialized</span>
<span class="c1">-- Is raised if AWS.Cookie.Set is called before the Content object has</span>
<span class="c1">-- been initialized by a call to AWS.Response.Build</span>
<span class="kd">procedure</span> <span class="nf">Set</span>
<span class="p">(</span><span class="nv">Content</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Integer</span><span class="p">;</span>
<span class="nv">Comment</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Domain</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Max_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Ten_Years</span><span class="p">;</span>
<span class="nv">Path</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"/"</span><span class="p">;</span>
<span class="nv">Secure</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Response</span><span class="p">.</span><span class="n">Mode</span> <span class="p">(</span><span class="n">Content</span><span class="p">)</span> <span class="o">/=</span> <span class="n">Response</span><span class="p">.</span><span class="n">No_Data</span><span class="p">;</span>
<span class="c1">-- Set a new cookie named 'Key' with Integer value 'Value'. The Integer is</span>
<span class="c1">-- converted to a String, as both cookie keys and values are inherently</span>
<span class="c1">-- strings.</span>
<span class="c1">--</span>
<span class="c1">-- Exceptions:</span>
<span class="c1">-- Response_Data_Not_Initialized</span>
<span class="c1">-- Is raised if AWS.Cookie.Set is called before the Content object has</span>
<span class="c1">-- been initialized by a call to AWS.Response.Build</span>
<span class="kd">procedure</span> <span class="nf">Set</span>
<span class="p">(</span><span class="nv">Content</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Float</span><span class="p">;</span>
<span class="nv">Comment</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Domain</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Max_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Ten_Years</span><span class="p">;</span>
<span class="nv">Path</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"/"</span><span class="p">;</span>
<span class="nv">Secure</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Response</span><span class="p">.</span><span class="n">Mode</span> <span class="p">(</span><span class="n">Content</span><span class="p">)</span> <span class="o">/=</span> <span class="n">Response</span><span class="p">.</span><span class="n">No_Data</span><span class="p">;</span>
<span class="c1">-- Set a new cookie named 'Key' with Float value 'Value'. The Float is</span>
<span class="c1">-- converted to a String, as both cookie keys and values are inherently</span>
<span class="c1">-- strings.</span>
<span class="c1">--</span>
<span class="c1">-- Exceptions:</span>
<span class="c1">-- Response_Data_Not_Initialized</span>
<span class="c1">-- Is raised if AWS.Cookie.Set is called before the Content object has</span>
<span class="c1">-- been initialized by a call to AWS.Response.Build</span>
<span class="kd">procedure</span> <span class="nf">Set</span>
<span class="p">(</span><span class="nv">Content</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">;</span>
<span class="nv">Comment</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Domain</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Max_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Ten_Years</span><span class="p">;</span>
<span class="nv">Path</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"/"</span><span class="p">;</span>
<span class="nv">Secure</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Response</span><span class="p">.</span><span class="n">Mode</span> <span class="p">(</span><span class="n">Content</span><span class="p">)</span> <span class="o">/=</span> <span class="n">Response</span><span class="p">.</span><span class="n">No_Data</span><span class="p">;</span>
<span class="c1">-- Set a new cookie named 'Key' with Boolean value 'Value'. The Boolean is</span>
<span class="c1">-- converted to a String ("False" or "True"), as both cookie keys and</span>
<span class="c1">-- values are inherently strings.</span>
<span class="c1">--</span>
<span class="c1">-- Exceptions:</span>
<span class="c1">-- Response_Data_Not_Initialized</span>
<span class="c1">-- Is raised if AWS.Cookie.Set is called before the Content object has</span>
<span class="c1">-- been initialized by a call to AWS.Response.Build</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Cookie</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-default">
<span id="id13"></span><h2>13.13. AWS.Default<a class="headerlink" href="#aws-default" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-11"><div class="highlight"><pre><span></span>------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2000-2014, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
-- This package contains the default AWS configuration values. These values
-- are used to initialize the configuration objects. Users should not modify
-- the values here, see AWS.Config.* API.
with System;
package AWS.Default with Pure is
use System;
-- All times are in seconds
Ten_Years : constant := 86_400.0 * 365 * 10;
One_Hour : constant := 3_600.0;
One_Minute : constant := 60.0;
Eight_Hours : constant := 8.0 * One_Hour;
Three_Hours : constant := 3.0 * One_Hour;
Three_Minutes : constant := 3.0 * One_Minute;
Five_Minutes : constant := 5.0 * One_Minute;
Ten_Minutes : constant := 10.0 * One_Minute;
-- Server configuration
Server_Name : constant String := "AWS Module";
WWW_Root : constant String := "./";
Admin_URI : constant String := "";
Admin_Password : constant String := "";
Admin_Realm : constant String := "AWS Admin Page";
Protocol_Family : constant String := "FAMILY_UNSPEC";
Server_Port : constant := 8080;
Hotplug_Port : constant := 8888;
Max_Connection : constant := 5;
Max_WebSocket_Handler : constant := 2;
Max_WebSocket : constant := 512;
WebSocket_Message_Queue_Size : constant := 10;
WebSocket_Timeout : constant Duration := Eight_Hours;
Send_Buffer_Size : constant := 0;
Free_Slots_Keep_Alive_Limit : constant := 1;
Keep_Alive_Force_Limit : constant := 0;
Keep_Alive_Close_Limit : constant := 0;
Accept_Queue_Size : constant := 64;
Upload_Directory : constant String := "";
Upload_Size_Limit : constant := 16#500_000#;
Line_Stack_Size : constant := 16#150_000#;
Case_Sensitive_Parameters : constant Boolean := True;
Input_Line_Size_Limit : constant := 16#4000#;
Max_POST_Parameters : constant := 100;
Max_Concurrent_Download : constant := 25;
Reuse_Address : constant Boolean := False;
MIME_Types : constant String := "aws.mime";
-- Client configuration
User_Agent : constant String :=
"AWS (Ada Web Server) v" & Version;
-- Log values. The character '@' in the error log filename prefix is
-- replaced by the running program name.
Log_File_Directory : constant String := "./";
Log_Split_Mode : constant String := "NONE";
Log_Filename_Prefix : constant String := "@";
Error_Log_Split_Mode : constant String := "NONE";
Error_Log_Filename_Prefix : constant String := "@_error";
Log_Size_Limit : constant Natural := 0;
-- Session
Session : constant Boolean := False;
Session_Name : constant String := "AWS";
Session_Cleanup_Interval : constant Duration := Five_Minutes;
Session_Lifetime : constant Duration := Ten_Minutes;
Session_Id_Length : constant Positive := 11;
-- Context
Context_Lifetime : constant Duration := Eight_Hours;
-- Transient pages
Transient_Cleanup_Interval : constant Duration := Three_Minutes;
Transient_Lifetime : constant Duration := Five_Minutes;
-- Server's timeouts
Cleaner_Wait_For_Client_Timeout : constant Duration := 80.0;
Cleaner_Client_Header_Timeout : constant Duration := 7.0;
Cleaner_Client_Data_Timeout : constant Duration := Eight_Hours;
Cleaner_Server_Response_Timeout : constant Duration := Eight_Hours;
Force_Wait_For_Client_Timeout : constant Duration := 2.0;
Force_Client_Header_Timeout : constant Duration := 2.0;
Force_Client_Data_Timeout : constant Duration := Three_Hours;
Force_Server_Response_Timeout : constant Duration := Three_Hours;
Send_Timeout : constant Duration := 40.0;
Receive_Timeout : constant Duration := 30.0;
-- Directory template
Directory_Browser_Page : constant String := "aws_directory.thtml";
-- Status page
Status_Page : constant String := "aws_status.thtml";
Up_Image : constant String := "aws_up.png";
Down_Image : constant String := "aws_down.png";
Logo_Image : constant String := "aws_logo.png";
-- Security
Security : constant Boolean := False;
Security_Mode : constant String := "SSLv23";
Config_Directory : constant String := ".config/ada-web-srv";
Cipher_Priorities : constant String := "";
TLS_Ticket_Support : constant Boolean := False;
Certificate : constant String := "cert.pem";
Key : constant String := "";
Client_Certificate : constant String := "";
Exchange_Certificate : constant Boolean := False;
Certificate_Required : constant Boolean := False;
Trusted_CA : constant String := "";
CRL_File : constant String := "";
Check_URL_Validity : constant Boolean := True;
SSL_Session_Cache_Size : constant := 16#4000#;
-- Priorities
Server_Priority : constant Any_Priority := Default_Priority;
WebSocket_Priority : constant Any_Priority := Default_Priority;
Session_Cleaner_Priority : constant Any_Priority := Default_Priority;
Service_Priority : constant Any_Priority := Default_Priority;
end AWS.Default;
</pre></div>
</div>
</div>
<div class="section" id="aws-dispatchers">
<span id="id14"></span><h2>13.14. AWS.Dispatchers<a class="headerlink" href="#aws-dispatchers" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-12"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package provides a service to build Callbacks which can support</span>
<span class="c1">-- user's data. It is possible to build a new dispatcher by inheriting the</span>
<span class="c1">-- handler type and to provides the Dispatch routine.</span>
<span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Dispatchers</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">new</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Finalization</span><span class="p">.</span><span class="kt">Controlled</span>
<span class="kr">and</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Utils</span><span class="p">.</span><span class="n">Clonable</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Dispatch</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Call the appropriate inherited dispatcher</span>
<span class="kd">function</span> <span class="nf">Ref_Counter</span> <span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Handler</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the reference counter for Handler. If 0 is returned then this</span>
<span class="c1">-- object is not referenced anymore, it is safe to deallocate resources.</span>
<span class="kd">type</span> <span class="kt">Handler_Class_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Free</span> <span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler_Class_Access</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Release memory associated with the dispatcher</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Dispatchers</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-dispatchers-callback">
<span id="id15"></span><h2>13.15. AWS.Dispatchers.Callback<a class="headerlink" href="#aws-dispatchers-callback" title="Permalink to this headline">¶</a></h2>
<span class="target" id="index-13"></span><div class="highlight-ada" id="index-14"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- Dispatch on a Callback procedure</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Dispatchers.Callback</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- This is a simple wrapper around standard callback procedure (access to</span>
<span class="c1">-- function). It will be used to build dispatchers services and for the</span>
<span class="c1">-- main server callback.</span>
<span class="kd">function</span> <span class="nf">Create</span> <span class="p">(</span><span class="nv">Callback</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Handler</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Build a dispatcher for the specified callback</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Dispatchers.Callback</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-exceptions">
<span id="id16"></span><h2>13.16. AWS.Exceptions<a class="headerlink" href="#aws-exceptions" title="Permalink to this headline">¶</a></h2>
<span class="target" id="index-15"></span><div class="highlight-ada" id="index-16"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Log</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Exceptions</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Data</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">Fatal</span> <span class="p">:</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- If True it means that we go a fatal error. The slot will be</span>
<span class="c1">-- terminated so AWS will loose one of it's simultaneous connection.</span>
<span class="c1">-- This is clearly an AWS internal error that should be fixed in AWS.</span>
<span class="n">Slot</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="c1">-- The failing slot number</span>
<span class="n">Request</span> <span class="p">:</span> <span class="n">Status</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- The complete request information that was served when the slot has</span>
<span class="c1">-- failed. This variable is set only when Fatal is False.</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Unexpected_Exception_Handler</span> <span class="kr">is</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span>
<span class="kd">procedure</span> <span class="p">(</span><span class="nv">E</span> <span class="p">: </span><span class="nv">Exception_Occurrence</span><span class="p">;</span>
<span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Error</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Answer</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">);</span>
<span class="c1">-- Unexpected exception handler can be set to monitor server errors.</span>
<span class="c1">-- Answer can be set with the answer to send back to the client's</span>
<span class="c1">-- browser. Note that this is possible only for non fatal error</span>
<span class="c1">-- (i.e. Error.Fatal is False).</span>
<span class="c1">-- Log is the error log object for the failing server, it can be used</span>
<span class="c1">-- to log user's information (if error log is activated for this</span>
<span class="c1">-- server). Note that the server will have already logged information</span>
<span class="c1">-- about the problem.</span>
<span class="kr">end</span> <span class="nf">AWS.Exceptions</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-headers">
<span id="id17"></span><h2>13.17. AWS.Headers<a class="headerlink" href="#aws-headers" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-17"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Containers.Tables</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Headers</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">List</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">Table_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Header container. This set handles a set of HTTP header line, each new</span>
<span class="c1">-- header line is inserted at the end of the list (see AWS.Headers.Set API)</span>
<span class="c1">-- and can be retrieved by the following services. Header lines are</span>
<span class="c1">-- numbered from 1 to N.</span>
<span class="no">Empty_List</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">List</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">VString_Array</span> <span class="kr">is</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">VString_Array</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Element</span> <span class="kr">is</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">Element</span><span class="p">;</span>
<span class="n">Format_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when header line format is wrong</span>
<span class="kd">procedure</span> <span class="nf">Send_Header</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Headers</span> <span class="p">: </span><span class="nv">List</span><span class="p">);</span>
<span class="c1">-- Send all header lines in Headers list to the socket</span>
<span class="kd">function</span> <span class="nf">Get_Line</span> <span class="p">(</span><span class="nv">Headers</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span>
<span class="p">(</span><span class="n">N</span> <span class="o">></span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Headers</span><span class="p">)</span> <span class="ow">and then</span> <span class="n">Get_Line</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
<span class="ow">or else</span> <span class="n">N</span> <span class="o"><=</span> <span class="kt">Count</span> <span class="p">(</span><span class="n">Headers</span><span class="p">);</span>
<span class="c1">-- Returns the Nth header line in Headers container. The returned value is</span>
<span class="c1">-- formatted as a correct header line:</span>
<span class="c1">--</span>
<span class="c1">-- message-header = field-name ":" [ field-value ]</span>
<span class="c1">--</span>
<span class="c1">-- That is the header-name followed with character ':' and the header</span>
<span class="c1">-- values. If there is less than Nth header line it returns the empty</span>
<span class="c1">-- string. Note that this routine does returns all header line values, for</span>
<span class="c1">-- example it would return:</span>
<span class="c1">--</span>
<span class="c1">-- Content_Type: multipart/mixed; boundary="0123_The_Boundary_Value_"</span>
<span class="c1">--</span>
<span class="c1">-- For a file upload content type header style.</span>
<span class="kd">function</span> <span class="nf">Get_Values</span> <span class="p">(</span><span class="nv">Headers</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns all values for the specified header field Name in a</span>
<span class="c1">-- comma-separated string. This format is conformant to [RFC 2616 - 4.2]</span>
<span class="c1">-- (see last paragraph).</span>
<span class="kd">function</span> <span class="nf">Length</span> <span class="p">(</span><span class="nv">Headers</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">List</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the length (in bytes) of the header, including the ending</span>
<span class="c1">-- empty line.</span>
<span class="kd">procedure</span> <span class="nf">Read</span> <span class="p">(</span><span class="nv">Headers</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span> <span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Read and parse HTTP header from the socket</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Headers</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Headers</span><span class="p">.</span><span class="kt">Count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Removes all object from Headers. Headers will be reinitialized and will</span>
<span class="c1">-- be ready for new use.</span>
<span class="kd">procedure</span> <span class="nf">Debug</span> <span class="p">(</span><span class="nv">Activate</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Turn on Debug output</span>
<span class="c1">-- See AWS.Containers.Tables for inherited routines</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Headers</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-headers-values">
<span id="id18"></span><h2>13.18. AWS.Headers.Values<a class="headerlink" href="#aws-headers-values" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-18"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Headers.Values</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">Format_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">Headers</span><span class="p">.</span><span class="n">Format_Error</span><span class="p">;</span>
<span class="c1">-- Data represent a token from an header line. There is two kinds of</span>
<span class="c1">-- token, either named or un-named.</span>
<span class="c1">--</span>
<span class="c1">-- Content-Type: xyz boundary="uvt"</span>
<span class="c1">--</span>
<span class="c1">-- Here xyz is an un-named value and uvt a named value the name is</span>
<span class="c1">-- boundary.</span>
<span class="kd">type</span> <span class="kt">Data</span> <span class="p">(</span><span class="nv">Named_Value</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">Value</span> <span class="p">:</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="kr">case</span> <span class="n">Named_Value</span> <span class="kr">is</span>
<span class="kr">when</span> <span class="kc">True</span> <span class="p">=></span>
<span class="n">Name</span> <span class="p">:</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="kr">when</span> <span class="kc">False</span> <span class="p">=></span>
<span class="kc">null</span><span class="p">;</span>
<span class="kr">end</span> <span class="kr">case</span><span class="p">;</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Data</span><span class="p">;</span>
<span class="c1">-----------</span>
<span class="c1">-- Parse --</span>
<span class="c1">-----------</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Value</span> <span class="p">(</span><span class="n">Item</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span> <span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="c1">-- Called for every un-named value read from the header value</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Named_Value</span>
<span class="p">(</span><span class="n">Name</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span>
<span class="n">Value</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="c1">-- Called for every named value read from the header value</span>
<span class="kd">procedure</span> <span class="nf">Parse</span> <span class="p">(</span><span class="nv">Header_Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Look for un-named values and named ones (Name="Value" pairs) in the</span>
<span class="c1">-- header line, and call appropriate routines when found. Quit is set to</span>
<span class="c1">-- False before calling Value or Named_Value, the parsing can be stopped</span>
<span class="c1">-- by setting Quit to True.</span>
<span class="c1">-------------------</span>
<span class="c1">-- Split / Index --</span>
<span class="c1">-------------------</span>
<span class="kd">function</span> <span class="nf">Split</span> <span class="p">(</span><span class="nv">Header_Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Set</span><span class="p">;</span>
<span class="c1">-- Returns a Set with each named and un-named values splited from Data</span>
<span class="kd">function</span> <span class="nf">Index</span>
<span class="p">(</span><span class="nv">Set</span> <span class="p">: </span><span class="nv">Values</span><span class="p">.</span><span class="nv">Set</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns index for Name in the set or 0 if Name not found.</span>
<span class="c1">-- If Case_Sensitive is false the find is case_insensitive.</span>
<span class="c1">---------------------------</span>
<span class="c1">-- Other search routines --</span>
<span class="c1">---------------------------</span>
<span class="kd">function</span> <span class="nf">Search</span>
<span class="p">(</span><span class="nv">Header_Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns Value for Name in Header_Value or the empty string if Name not</span>
<span class="c1">-- found. If Case_Sensitive is False the search is case insensitive.</span>
<span class="kd">function</span> <span class="nf">Get_Unnamed_Value</span>
<span class="p">(</span><span class="nv">Header_Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns N-th un-named value from Header_Value</span>
<span class="kd">function</span> <span class="nf">Unnamed_Value_Exists</span>
<span class="p">(</span><span class="nv">Header_Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Case_Sensitive</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the unnamed value specified has been found in</span>
<span class="c1">-- Header_Value.</span>
<span class="kr">end</span> <span class="nf">AWS.Headers.Values</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-jabber">
<span id="id19"></span><h2>13.19. AWS.Jabber<a class="headerlink" href="#aws-jabber" title="Permalink to this headline">¶</a></h2>
<span class="target" id="index-19"></span><div class="highlight-ada" id="index-20"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Jabber</span> <span class="nc">with</span> <span class="nc">Pure</span> <span class="kr">is</span>
<span class="kr">end</span> <span class="nf">AWS.Jabber</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-ldap-client">
<span id="id20"></span><h2>13.20. AWS.LDAP.Client<a class="headerlink" href="#aws-ldap-client" title="Permalink to this headline">¶</a></h2>
<span class="target" id="index-21"></span><div class="highlight-ada" id="index-22"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Provides an API to add, read, modify and delete information from a LDAP</span>
<span class="c1">-- server. It is a thick binding, see AWS.LDAP.Thin for a thin binding.</span>
<span class="c1">--</span>
<span class="c1">-- This API has been tested on Windows and Linux (OpenLDAP).</span>
<span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Vectors</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.LDAP.Thin</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.LDAP.Client</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">LDAP_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">LDAP</span><span class="p">.</span><span class="n">LDAP_Error</span><span class="p">;</span>
<span class="no">Default_Port</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">Positive</span> <span class="p">:=</span> <span class="kt">Positive</span> <span class="p">(</span><span class="n">Thin</span><span class="p">.</span><span class="n">LDAP_PORT</span><span class="p">);</span>
<span class="kd">subtype</span> <span class="kt">Directory</span> <span class="kr">is</span> <span class="n">Thin</span><span class="p">.</span><span class="n">LDAP_Type</span><span class="p">;</span>
<span class="c1">-- An LDAP directory. This object must be initialized with Init and Bind</span>
<span class="c1">-- and terminated with Unbind.</span>
<span class="kd">subtype</span> <span class="kt">LDAP_Message</span> <span class="kr">is</span> <span class="n">Thin</span><span class="p">.</span><span class="n">LDAPMessage</span><span class="p">;</span>
<span class="c1">-- An LDAP message or set of messages. There is a set of iterators to</span>
<span class="c1">-- access all messages returned by the search procedure.</span>
<span class="kd">subtype</span> <span class="kt">BER_Element</span> <span class="kr">is</span> <span class="n">Thin</span><span class="p">.</span><span class="n">BerElement</span><span class="p">;</span>
<span class="c1">-- An iterator structure. Initialized and used to iterate through all the</span>
<span class="c1">-- attributes for a specific message.</span>
<span class="no">Null_Directory</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Directory</span> <span class="p">:=</span> <span class="n">Thin</span><span class="p">.</span><span class="n">Null_LDAP_Type</span><span class="p">;</span>
<span class="no">Null_LDAP_Message</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">LDAP_Message</span> <span class="p">:=</span> <span class="n">Thin</span><span class="p">.</span><span class="n">Null_LDAPMessage</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Scope_Type</span> <span class="kr">is</span>
<span class="p">(</span><span class="nv">LDAP_Scope_Default</span><span class="p">,</span> <span class="nv">LDAP_Scope_Base</span><span class="p">,</span>
<span class="nv">LDAP_Scope_One_Level</span><span class="p">,</span> <span class="nv">LDAP_Scope_Subtree</span><span class="p">);</span>
<span class="c1">-- LDAP scope for the search</span>
<span class="kd">type</span> <span class="kt">String_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- A set of strings, this is used to map C array of strings (a char **)</span>
<span class="c1">-- from the thin binding.</span>
<span class="no">Null_Set</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">String_Set</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Get_Error</span> <span class="p">(</span><span class="nv">E</span> <span class="p">: </span><span class="nv">Exception_Occurrence</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Thin</span><span class="p">.</span><span class="n">Return_Code</span><span class="p">;</span>
<span class="c1">-- Returns the error code in the LDAP_Error exception occurence E. Returns</span>
<span class="c1">-- Think.LDAP_SUCCESS if no error code has been found.</span>
<span class="c1">----------------</span>
<span class="c1">-- Attributes --</span>
<span class="c1">----------------</span>
<span class="kd">subtype</span> <span class="kt">Attribute_Set</span> <span class="kr">is</span> <span class="n">String_Set</span><span class="p">;</span>
<span class="c1">-- Used to represent the set of attributes to retrieve from the LDAP server</span>
<span class="kd">function</span> <span class="nf">Attributes</span>
<span class="p">(</span><span class="nv">S1</span><span class="p">,</span> <span class="nv">S2</span><span class="p">,</span> <span class="nv">S3</span><span class="p">,</span> <span class="nv">S4</span><span class="p">,</span> <span class="nv">S5</span><span class="p">,</span> <span class="nv">S6</span><span class="p">,</span> <span class="nv">S7</span><span class="p">,</span> <span class="nv">S8</span><span class="p">,</span> <span class="nv">S9</span><span class="p">,</span> <span class="nv">S10</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Attribute_Set</span><span class="p">;</span>
<span class="c1">-- Returns a String_Set object containing only none empty values. Values</span>
<span class="c1">-- for S1 through S10 must be set in the order of the parameters. This is</span>
<span class="c1">-- an helper routine to help building an array of unbounded string from a</span>
<span class="c1">-- set of string.</span>
<span class="kd">function</span> <span class="nf">uid</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the uid attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">givenName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the given name (firstname) attribute. if Val is specified</span>
<span class="c1">-- "=<Val>" is added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">cn</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">commonName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">cn</span><span class="p">;</span>
<span class="c1">-- Returns the common Name attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">sn</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">surname</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">sn</span><span class="p">;</span>
<span class="c1">-- Returns the surname attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">telephoneNumber</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the phone number. if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name. Val must use the international notation</span>
<span class="c1">-- according to CCITT E.123.</span>
<span class="kd">function</span> <span class="nf">mail</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the mail attribute. if Val is specified "=<Val>" is added after</span>
<span class="c1">-- the attribute name.</span>
<span class="kd">function</span> <span class="nf">l</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">localityName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">l</span><span class="p">;</span>
<span class="c1">-- Returns the locality attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">o</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">organizationName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">o</span><span class="p">;</span>
<span class="c1">-- Returns the organization attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">ou</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">organizationalUnitName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kr">renames</span> <span class="n">ou</span><span class="p">;</span>
<span class="c1">-- Returns the organizational unit attribute, if Val is specified "=<Val>"</span>
<span class="c1">-- is added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">st</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">stateOrProvinceName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kr">renames</span> <span class="n">st</span><span class="p">;</span>
<span class="c1">-- Returns the state name attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">c</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">countryName</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">c</span><span class="p">;</span>
<span class="c1">-- Returns country code attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name. Val must be a two-letter ISO 3166</span>
<span class="c1">-- country code.</span>
<span class="kd">function</span> <span class="nf">dc</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">domainComponent</span> <span class="p">(</span><span class="nv">Val</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">dc</span><span class="p">;</span>
<span class="c1">-- Returns a domain component attribute, if Val is specified "=<Val>" is</span>
<span class="c1">-- added after the attribute name.</span>
<span class="kd">function</span> <span class="nf">Cat</span>
<span class="p">(</span><span class="nv">S1</span><span class="p">,</span> <span class="nv">S2</span><span class="p">,</span> <span class="nv">S3</span><span class="p">,</span> <span class="nv">S4</span><span class="p">,</span> <span class="nv">S5</span><span class="p">,</span> <span class="nv">S6</span><span class="p">,</span> <span class="nv">S7</span><span class="p">,</span> <span class="nv">S8</span><span class="p">,</span> <span class="nv">S9</span><span class="p">,</span> <span class="nv">S10</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns a string object containing only none empty values. Values for</span>
<span class="c1">-- S1 through S10 must be set in the order of the parameters. All values</span>
<span class="c1">-- are catenated and separated with a coma. This is an helper routine to</span>
<span class="c1">-- help building a filter objects or base distinguished name.</span>
<span class="c1">----------------</span>
<span class="c1">-- Initialize --</span>
<span class="c1">----------------</span>
<span class="kd">function</span> <span class="nf">Init</span>
<span class="p">(</span><span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Default_Port</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Directory</span><span class="p">;</span>
<span class="c1">-- Must be called first, to initialize the LDAP communication with the</span>
<span class="c1">-- server. Returns Null_Directory in case of error.</span>
<span class="kd">procedure</span> <span class="nf">Bind</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Login</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Bind to the server by providing a login and password</span>
<span class="kd">procedure</span> <span class="nf">Unbind</span> <span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Directory</span><span class="p">);</span>
<span class="c1">-- Must be called to release resources associated with the Directory. Does</span>
<span class="c1">-- nothing if Dir is Null_Directory.</span>
<span class="kd">function</span> <span class="nf">Is_Open</span> <span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the directory has correctly been initialized and binded</span>
<span class="c1">-- with the server.</span>
<span class="c1">------------</span>
<span class="c1">-- Search --</span>
<span class="c1">------------</span>
<span class="kd">function</span> <span class="nf">Search</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Base</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Filter</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Scope</span> <span class="p">: </span><span class="nv">Scope_Type</span> <span class="p">:=</span> <span class="nv">LDAP_Scope_Default</span><span class="p">;</span>
<span class="nv">Attrs</span> <span class="p">: </span><span class="nv">Attribute_Set</span> <span class="p">:=</span> <span class="nv">Null_Set</span><span class="p">;</span>
<span class="nv">Attrs_Only</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="n">LDAP_Message</span><span class="p">;</span>
<span class="c1">-- Do a search on the LDAP server. Base is the name of the database.</span>
<span class="c1">-- Filter can be used to retrieve a specific set of entries. Attrs specify</span>
<span class="c1">-- the set of attributes to retrieve. If Attrs_Only is set to True only</span>
<span class="c1">-- the types are returned. Raises LDAP_Error in case of problem.</span>
<span class="c1">-----------------------</span>
<span class="c1">-- Add/Modify/Delete --</span>
<span class="c1">-----------------------</span>
<span class="kd">type</span> <span class="kt">Mod_Type</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">LDAP_Mod_Add</span><span class="p">,</span> <span class="nv">LDAP_Mod_Replace</span><span class="p">,</span> <span class="nv">LDAP_Mod_BValues</span><span class="p">);</span>
<span class="c1">-- Modification types: Add, Replace and BER flag</span>
<span class="kd">type</span> <span class="kt">Mod_Element</span> <span class="p">(</span><span class="nv">Values_Size</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">Mod_Op</span> <span class="p">:</span> <span class="n">Mod_Type</span><span class="p">;</span>
<span class="n">Mod_Type</span> <span class="p">:</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="n">Mod_Values</span> <span class="p">:</span> <span class="n">Attribute_Set</span> <span class="p">(</span><span class="mi">1</span> <span class="p">..</span> <span class="n">Values_Size</span><span class="p">);</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="c1">-- Holds modification elements. 'Abstraction' of the LDAPMod_Element type</span>
<span class="c1">-- used in the thin-binding. Mod_Values is static to make it less complex.</span>
<span class="kd">package</span> <span class="nc">LDAP_Mods</span> <span class="kr">is</span>
<span class="kr"> new</span> <span class="nc">Ada.Containers.Indefinite_Vectors</span> <span class="p">(</span>Positive<span class="p">,</span> Mod_Element<span class="p">);</span>
<span class="c1">-- Vector-based Storage for all modification elements. Will be</span>
<span class="c1">-- mapped to C LDAPMod **.</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">DN</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Mods</span> <span class="p">: </span><span class="nv">LDAP_Mods</span><span class="p">.</span><span class="nv">Vector</span><span class="p">);</span>
<span class="c1">-- Add an entry specified by 'DN' to the LDAP server. The Mods-Vector</span>
<span class="c1">-- contains the attributes for the entry.</span>
<span class="kd">procedure</span> <span class="nf">Modify</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">DN</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Mods</span> <span class="p">: </span><span class="nv">LDAP_Mods</span><span class="p">.</span><span class="nv">Vector</span><span class="p">);</span>
<span class="c1">-- Modify an attribute of entry specified by 'DN'. The Mods-Vector</span>
<span class="c1">-- contains the attributes to add/replace/delete for the entry.</span>
<span class="kd">procedure</span> <span class="nf">Delete</span> <span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span> <span class="nv">DN</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Delete an entry specified by 'DN' from the LDAP server</span>
<span class="c1">---------------</span>
<span class="c1">-- Iterators --</span>
<span class="c1">---------------</span>
<span class="kd">function</span> <span class="nf">First_Entry</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Chain</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">)</span> <span class="kr">return</span> <span class="n">LDAP_Message</span><span class="p">;</span>
<span class="c1">-- Returns the first entry (or Node) for the search result (Chain)</span>
<span class="kd">function</span> <span class="nf">Next_Entry</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Entries</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">)</span> <span class="kr">return</span> <span class="n">LDAP_Message</span><span class="p">;</span>
<span class="c1">-- Returns next entry (or Node) for Entries</span>
<span class="kd">function</span> <span class="nf">Count_Entries</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Chain</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of entries in the search result (Chain)</span>
<span class="kd">procedure</span> <span class="nf">Free</span> <span class="p">(</span><span class="nv">Chain</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">);</span>
<span class="c1">-- Release memory associated with the search result Chain</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">Node</span> <span class="p">:</span> <span class="n">LDAP_Message</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Entry</span> <span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span> <span class="nv">Chain</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">);</span>
<span class="c1">-- This iterator call Action for each entry (Node) found in the LDAP result</span>
<span class="c1">-- set as returned by the search procedure. Quit can be set to True to</span>
<span class="c1">-- stop iteration; its initial value is False.</span>
<span class="kd">function</span> <span class="nf">First_Attribute</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Node</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">;</span>
<span class="nv">BER</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">BER_Element</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the first attribute for the entry. It initialize an iteraror</span>
<span class="c1">-- (the BER structure). The BER structure must be released after used by</span>
<span class="c1">-- using the Free routine below.</span>
<span class="kd">function</span> <span class="nf">Next_Attribute</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Node</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">;</span>
<span class="nv">BER</span> <span class="p">: </span><span class="nv">BER_Element</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns next attribute for iterator BER. First_Attribute must have been</span>
<span class="c1">-- called to initialize this iterator.</span>
<span class="kd">procedure</span> <span class="nf">Free</span> <span class="p">(</span><span class="nv">BER</span> <span class="p">: </span><span class="nv">BER_Element</span><span class="p">);</span>
<span class="c1">-- Releases memory associated with the BER structure which has been</span>
<span class="c1">-- allocated by the First_Attribute routine.</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">Attribute</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Attribute</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Node</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">);</span>
<span class="c1">-- This iterator call action for each attribute found in the LDAP Entries</span>
<span class="c1">-- Node as returned by First_Entry or Next_Entry. Quit can be set to True</span>
<span class="c1">-- to stop iteration; its initial value is False.</span>
<span class="c1">---------------</span>
<span class="c1">-- Accessors --</span>
<span class="c1">---------------</span>
<span class="kd">function</span> <span class="nf">Get_DN</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Node</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the distinguished name for the given entry Node</span>
<span class="kd">function</span> <span class="nf">DN2UFN</span> <span class="p">(</span><span class="nv">DN</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns a distinguished name converted to a user-friendly format</span>
<span class="kd">function</span> <span class="nf">Get_Values</span>
<span class="p">(</span><span class="nv">Dir</span> <span class="p">: </span><span class="nv">Directory</span><span class="p">;</span>
<span class="nv">Node</span> <span class="p">: </span><span class="nv">LDAP_Message</span><span class="p">;</span>
<span class="nv">Target</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">String_Set</span><span class="p">;</span>
<span class="c1">-- Returns the list of values of a given attribute (Target) found in entry</span>
<span class="c1">-- Node.</span>
<span class="kd">function</span> <span class="nf">Explode_DN</span>
<span class="p">(</span><span class="nv">DN</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">No_Types</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="n">String_Set</span><span class="p">;</span>
<span class="c1">-- Breaks up an entry name into its component parts. If No_Types is set to</span>
<span class="c1">-- True the types information ("cn=") won't be included.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.LDAP.Client</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-log">
<span id="id21"></span><h2>13.21. AWS.Log<a class="headerlink" href="#aws-log" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-23"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- This package handle the logging facility for AWS. The log file is named</span>
<span class="c1">-- '<progname>-Y-M-D.log' and is written by default in the directory where</span>
<span class="c1">-- the server is launched, see configuration file.</span>
<span class="c1">--</span>
<span class="c1">-- Note that this package is used internally by AWS to log server requests</span>
<span class="c1">-- but it can also be used by users to handle application's log.</span>
<span class="c1">--</span>
<span class="c1">-- This package is thread safe.</span>
<span class="kn">with</span> <span class="nn">AWS.Containers.String_Vectors</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Headers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Messages</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Ordered_Maps</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Text_IO</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Log</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- A log object. It must be activated by calling Start below</span>
<span class="kd">type</span> <span class="kt">Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Access to a procedure that handles AWS access and/or error log data.</span>
<span class="c1">-- If the access and/or error logs are started with a Callback procedure</span>
<span class="c1">-- set, then AWS will no longer handle writing the log data to file, nor</span>
<span class="c1">-- will it rotate or split the data. In short : If you set a Callback, it's</span>
<span class="c1">-- up to you to handle these things.</span>
<span class="c1">-- The raw log data generated by AWS is simply handed verbatim to the</span>
<span class="c1">-- Callback procedure.</span>
<span class="kd">type</span> <span class="kt">Split_Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">None</span><span class="p">,</span> <span class="nv">Each_Run</span><span class="p">,</span> <span class="nv">Daily</span><span class="p">,</span> <span class="nv">Monthly</span><span class="p">);</span>
<span class="c1">-- It specifies when to create a new log file.</span>
<span class="c1">-- None : all log info gets accumulated into the same file.</span>
<span class="c1">-- Each_Run : a new log file is created each time the server is started.</span>
<span class="c1">-- Daily : a new log file is created each day.</span>
<span class="c1">-- Monthly : a new log file is created each month.</span>
<span class="kd">type</span> <span class="kt">Fields_Table</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Type to keep record for Extended Log File Format</span>
<span class="no">Empty_Fields_Table</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Fields_Table</span><span class="p">;</span>
<span class="no">Not_Specified</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Split</span> <span class="p">: </span><span class="nv">Split_Mode</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">;</span>
<span class="nv">Size_Limit</span> <span class="p">: </span><span class="nv">Natural</span> <span class="p">:=</span> <span class="nv">0</span><span class="p">;</span>
<span class="nv">File_Directory</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Filename_Prefix</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Auto_Flush</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Activate server's activity logging. Split indicate the way the log file</span>
<span class="c1">-- should be created. If Size_Limit more than zero and size of log file</span>
<span class="c1">-- become more than Size_Limit, log file would be splitted. Filename_Prefix</span>
<span class="c1">-- is the log filename prefix. If it is not specified the default prefix is</span>
<span class="c1">-- the program name. Set Auto_Flush to True if you want every write to the</span>
<span class="c1">-- log to be flushed (not buffered). Auto_Flush should be set to True only</span>
<span class="c1">-- for logs with few entries per second as the flush has a performance</span>
<span class="c1">-- penalty.</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Writer</span> <span class="p">: </span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Activate server's activity logging and send all log data to Callback.</span>
<span class="c1">-- When the logging object is started with a Callback no splitting or size</span>
<span class="c1">-- limits are imposed on the logging data. This will all have to be handled</span>
<span class="c1">-- in the Callback.</span>
<span class="c1">-- When a log is started with a Callback, all log data is passed verbatim</span>
<span class="c1">-- to the Callback.</span>
<span class="c1">-- The Name String is returned when the Filename function is called. This</span>
<span class="c1">-- serves no other function than to label the Callback procedure.</span>
<span class="kd">procedure</span> <span class="nf">Register_Field</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Id</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Register field to be written into extended log format</span>
<span class="kd">procedure</span> <span class="nf">Set_Field</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Data</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Fields_Table</span><span class="p">;</span> <span class="nv">Id</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set field value into the extended log record. Data could be used only</span>
<span class="c1">-- in one task and with one log file. Different tasks could write own Data</span>
<span class="c1">-- using the Write routine with Fields_Table parameter type.</span>
<span class="kd">procedure</span> <span class="nf">Set_Header_Fields</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Fields_Table</span><span class="p">;</span>
<span class="nv">Prefix</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Header</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Headers</span><span class="p">.</span><span class="nv">List</span><span class="p">);</span>
<span class="c1">-- Set header fields into extended log record.</span>
<span class="c1">-- Name of the header fields would be <Prefix>(<Header_Name>).</span>
<span class="c1">-- Prefix should be "cs" - Client to Server or "sc" - Server to Client.</span>
<span class="kd">procedure</span> <span class="nf">Write</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Data</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Fields_Table</span><span class="p">);</span>
<span class="c1">-- Write extended format record to log file and prepare record for the next</span>
<span class="c1">-- data. It is not allowed to use same Fields_Table with different extended</span>
<span class="c1">-- logs.</span>
<span class="kd">procedure</span> <span class="nf">Write</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Connect_Stat</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Answer</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Data</span><span class="p">);</span>
<span class="c1">-- Write log info if activated (i.e. Start routine above has been called)</span>
<span class="kd">procedure</span> <span class="nf">Write</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Connect_Stat</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span><span class="p">;</span>
<span class="nv">Content_Length</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Content_Length_Type</span><span class="p">);</span>
<span class="c1">-- Write log info if activated (i.e. Start routine above has been called).</span>
<span class="c1">-- This version separated the Content_Length from Status.Data, this is</span>
<span class="c1">-- required for example in the case of a user defined stream content. See</span>
<span class="c1">-- AWS.Resources.Stream.</span>
<span class="kd">procedure</span> <span class="nf">Write</span>
<span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Connect_Stat</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Write user's log info if activated. (i.e. Start routine above has been</span>
<span class="c1">-- called).</span>
<span class="kd">procedure</span> <span class="nf">Write</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Write Data into the log file. This Data is unstructured, only a time</span>
<span class="c1">-- tag prefix is prepended to Data. This routine is designed to be used</span>
<span class="c1">-- for user's info in error log file.</span>
<span class="kd">procedure</span> <span class="nf">Flush</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Flush the data to the Log file, for be able to see last logged</span>
<span class="c1">-- messages.</span>
<span class="c1">-- If a Callback procedure is used to handle the log data, then calling</span>
<span class="c1">-- Flush does nothing.</span>
<span class="kd">procedure</span> <span class="nf">Stop</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Stop logging activity</span>
<span class="kd">function</span> <span class="nf">Is_Active</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if Log is activated</span>
<span class="kd">function</span> <span class="nf">Filename</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns current log filename or the empty string if the log is not</span>
<span class="c1">-- activated.</span>
<span class="c1">-- If a Callback is used to handle the log, then the name given in the</span>
<span class="c1">-- Start procedure is returned. See the Start procedure for starting logs</span>
<span class="c1">-- with a Callback.</span>
<span class="kd">function</span> <span class="nf">Mode</span> <span class="p">(</span><span class="nv">Log</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Split_Mode</span><span class="p">;</span>
<span class="c1">-- Returns the split mode. None will be returned if log is not activated or</span>
<span class="c1">-- a Callback procedure is used to handle the log data.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Log</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-messages">
<span id="id22"></span><h2>13.22. AWS.Messages<a class="headerlink" href="#aws-messages" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-24"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Messages</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="c1">-----------------</span>
<span class="c1">-- HTTP tokens --</span>
<span class="c1">-----------------</span>
<span class="no">HTTP_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"HTTP/"</span><span class="p">;</span>
<span class="no">Options_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"OPTIONS"</span><span class="p">;</span>
<span class="no">Get_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"GET"</span><span class="p">;</span>
<span class="no">Head_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"HEAD"</span><span class="p">;</span>
<span class="no">Post_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"POST"</span><span class="p">;</span>
<span class="no">Put_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"PUT"</span><span class="p">;</span>
<span class="no">Delete_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"DELETE"</span><span class="p">;</span>
<span class="no">Trace_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"TRACE"</span><span class="p">;</span>
<span class="no">Connect_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"CONNECT"</span><span class="p">;</span>
<span class="c1">-- Sorted like in RFC 2616 Method definition</span>
<span class="c1">------------------------</span>
<span class="c1">-- HTTP header tokens --</span>
<span class="c1">------------------------</span>
<span class="c1">-- General header tokens RFC 2616</span>
<span class="no">Cache_Control_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Cache-Control"</span><span class="p">;</span>
<span class="no">Connection_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Connection"</span><span class="p">;</span>
<span class="no">Date_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Date"</span><span class="p">;</span>
<span class="no">Pragma_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Pragma"</span><span class="p">;</span>
<span class="no">Trailer_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Trailer"</span><span class="p">;</span>
<span class="no">Transfer_Encoding_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Transfer-Encoding"</span><span class="p">;</span>
<span class="no">Upgrade_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Upgrade"</span><span class="p">;</span>
<span class="no">Via_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Via"</span><span class="p">;</span>
<span class="no">Warning_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Warning"</span><span class="p">;</span>
<span class="c1">-- Request header tokens RFC 2616</span>
<span class="no">Accept_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Accept"</span><span class="p">;</span>
<span class="no">Accept_Charset_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Accept-Charset"</span><span class="p">;</span>
<span class="no">Accept_Encoding_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Accept-Encoding"</span><span class="p">;</span>
<span class="no">Accept_Language_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Accept-Language"</span><span class="p">;</span>
<span class="no">Authorization_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Authorization"</span><span class="p">;</span>
<span class="no">Expect_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Expect"</span><span class="p">;</span>
<span class="no">From_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"From"</span><span class="p">;</span>
<span class="no">Host_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Host"</span><span class="p">;</span>
<span class="no">If_Match_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"If-Match"</span><span class="p">;</span>
<span class="no">If_Modified_Since_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"If-Modified-Since"</span><span class="p">;</span>
<span class="no">If_None_Match_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"If-None-Match"</span><span class="p">;</span>
<span class="no">If_Range_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"If-Range"</span><span class="p">;</span>
<span class="no">If_Unmodified_Since_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"If-Unmodified-Since"</span><span class="p">;</span>
<span class="no">Max_Forwards_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Max-Forwards"</span><span class="p">;</span>
<span class="no">Proxy_Authorization_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Proxy-Authorization"</span><span class="p">;</span>
<span class="no">Range_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Range"</span><span class="p">;</span>
<span class="no">Referer_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Referer"</span><span class="p">;</span>
<span class="no">TE_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"TE"</span><span class="p">;</span>
<span class="no">User_Agent_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"User-Agent"</span><span class="p">;</span>
<span class="c1">-- Cross-Origin Resource Sharing request header tokens</span>
<span class="no">Access_Control_Request_Headers_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Request-Headers"</span><span class="p">;</span>
<span class="no">Access_Control_Request_Method_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Request-Method"</span><span class="p">;</span>
<span class="no">Origin_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Origin"</span><span class="p">;</span>
<span class="c1">-- Response header tokens RFC 2616</span>
<span class="no">Accept_Ranges_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Accept-Ranges"</span><span class="p">;</span>
<span class="no">Age_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Age"</span><span class="p">;</span>
<span class="no">ETag_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"ETag"</span><span class="p">;</span>
<span class="no">Location_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Location"</span><span class="p">;</span>
<span class="no">Proxy_Authenticate_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Proxy-Authenticate"</span><span class="p">;</span>
<span class="no">Retry_After_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Retry-After"</span><span class="p">;</span>
<span class="no">Server_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Server"</span><span class="p">;</span>
<span class="no">Vary_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Vary"</span><span class="p">;</span>
<span class="no">WWW_Authenticate_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"WWW-Authenticate"</span><span class="p">;</span>
<span class="c1">-- Cross-Origin Resource Sharing response header tokens</span>
<span class="no">Access_Control_Allow_Credentials_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Allow-Credentials"</span><span class="p">;</span>
<span class="no">Access_Control_Allow_Headers_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Allow-Headers"</span><span class="p">;</span>
<span class="no">Access_Control_Allow_Methods_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Allow-Methods"</span><span class="p">;</span>
<span class="no">Access_Control_Allow_Origin_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Allow-Origin"</span><span class="p">;</span>
<span class="no">Access_Control_Expose_Headers_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Expose-Headers"</span><span class="p">;</span>
<span class="no">Access_Control_Max_Age_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Access-Control-Max-Age"</span><span class="p">;</span>
<span class="c1">-- Entity header tokens RFC 2616</span>
<span class="no">Allow_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Allow"</span><span class="p">;</span>
<span class="no">Content_Encoding_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Encoding"</span><span class="p">;</span>
<span class="no">Content_Language_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Language"</span><span class="p">;</span>
<span class="no">Content_Length_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Length"</span><span class="p">;</span>
<span class="no">Content_Location_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Location"</span><span class="p">;</span>
<span class="no">Content_MD5_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-MD5"</span><span class="p">;</span>
<span class="no">Content_Range_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Range"</span><span class="p">;</span>
<span class="no">Content_Type_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Type"</span><span class="p">;</span>
<span class="no">Expires_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Expires"</span><span class="p">;</span>
<span class="no">Last_Modified_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Last-Modified"</span><span class="p">;</span>
<span class="c1">-- Cookie token RFC 2109</span>
<span class="no">Cookie_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Cookie"</span><span class="p">;</span>
<span class="no">Set_Cookie_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Set-Cookie"</span><span class="p">;</span>
<span class="no">Comment_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Comment"</span><span class="p">;</span>
<span class="no">Domain_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Domain"</span><span class="p">;</span>
<span class="no">Max_Age_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Max-Age"</span><span class="p">;</span>
<span class="no">Path_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Path"</span><span class="p">;</span>
<span class="no">Secure_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Secure"</span><span class="p">;</span>
<span class="c1">-- Other tokens</span>
<span class="no">Proxy_Connection_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Proxy-Connection"</span><span class="p">;</span>
<span class="no">Content_Disposition_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-Disposition"</span><span class="p">;</span>
<span class="no">SOAPAction_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"SOAPAction"</span><span class="p">;</span>
<span class="no">Content_Id_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Content-ID"</span><span class="p">;</span>
<span class="no">Content_Transfer_Encoding_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"Content-Transfer-Encoding"</span><span class="p">;</span>
<span class="c1">-- WebSockets tokens</span>
<span class="no">Websocket_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"WebSocket"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Accept_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Accept"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Protocol_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Protocol"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Key_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Key"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Key1_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Key1"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Key2_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Key2"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Version_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Version"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Origin_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Origin"</span><span class="p">;</span>
<span class="no">Sec_WebSocket_Location_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"Sec-WebSocket-Location"</span><span class="p">;</span>
<span class="no">Chat_Token</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"chat"</span><span class="p">;</span>
<span class="no">S100_Continue</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"100-continue"</span><span class="p">;</span>
<span class="c1">-- Supported expect header value</span>
<span class="c1">-----------------</span>
<span class="c1">-- Status Code --</span>
<span class="c1">-----------------</span>
<span class="kd">type</span> <span class="kt">Status_Code</span> <span class="kr">is</span>
<span class="p">(</span><span class="nv">S100</span><span class="p">,</span> <span class="nv">S101</span><span class="p">,</span> <span class="nv">S102</span><span class="p">,</span>
<span class="c1">-- 1xx : Informational - Request received, continuing process</span>
<span class="nv">S200</span><span class="p">,</span> <span class="nv">S201</span><span class="p">,</span> <span class="nv">S202</span><span class="p">,</span> <span class="nv">S203</span><span class="p">,</span> <span class="nv">S204</span><span class="p">,</span> <span class="nv">S205</span><span class="p">,</span> <span class="nv">S206</span><span class="p">,</span> <span class="nv">S207</span><span class="p">,</span>
<span class="c1">-- 2xx : Success - The action was successfully received, understood and</span>
<span class="c1">-- accepted</span>
<span class="nv">S300</span><span class="p">,</span> <span class="nv">S301</span><span class="p">,</span> <span class="nv">S302</span><span class="p">,</span> <span class="nv">S303</span><span class="p">,</span> <span class="nv">S304</span><span class="p">,</span> <span class="nv">S305</span><span class="p">,</span> <span class="nv">S307</span><span class="p">,</span>
<span class="c1">-- 3xx : Redirection - Further action must be taken in order to</span>
<span class="c1">-- complete the request</span>
<span class="nv">S400</span><span class="p">,</span> <span class="nv">S401</span><span class="p">,</span> <span class="nv">S402</span><span class="p">,</span> <span class="nv">S403</span><span class="p">,</span> <span class="nv">S404</span><span class="p">,</span> <span class="nv">S405</span><span class="p">,</span> <span class="nv">S406</span><span class="p">,</span> <span class="nv">S407</span><span class="p">,</span> <span class="nv">S408</span><span class="p">,</span> <span class="nv">S409</span><span class="p">,</span>
<span class="nv">S410</span><span class="p">,</span> <span class="nv">S411</span><span class="p">,</span> <span class="nv">S412</span><span class="p">,</span> <span class="nv">S413</span><span class="p">,</span> <span class="nv">S414</span><span class="p">,</span> <span class="nv">S415</span><span class="p">,</span> <span class="nv">S416</span><span class="p">,</span> <span class="nv">S417</span><span class="p">,</span> <span class="nv">S422</span><span class="p">,</span> <span class="nv">S423</span><span class="p">,</span> <span class="nv">S424</span><span class="p">,</span>
<span class="c1">-- 4xx : Client Error - The request contains bad syntax or cannot be</span>
<span class="c1">-- fulfilled</span>
<span class="nv">S500</span><span class="p">,</span> <span class="nv">S501</span><span class="p">,</span> <span class="nv">S502</span><span class="p">,</span> <span class="nv">S503</span><span class="p">,</span> <span class="nv">S504</span><span class="p">,</span> <span class="nv">S505</span><span class="p">,</span> <span class="nv">S507</span>
<span class="c1">-- 5xx : Server Error - The server failed to fulfill an apparently</span>
<span class="c1">-- valid request</span>
<span class="p">);</span>
<span class="kd">subtype</span> <span class="kt">Informational</span> <span class="kr">is</span> <span class="n">Status_Code</span> <span class="kr">range</span> <span class="n">S100</span> <span class="p">..</span> <span class="n">S102</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Success</span> <span class="kr">is</span> <span class="n">Status_Code</span> <span class="kr">range</span> <span class="n">S200</span> <span class="p">..</span> <span class="n">S207</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Redirection</span> <span class="kr">is</span> <span class="n">Status_Code</span> <span class="kr">range</span> <span class="n">S300</span> <span class="p">..</span> <span class="n">S307</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Client_Error</span> <span class="kr">is</span> <span class="n">Status_Code</span> <span class="kr">range</span> <span class="n">S400</span> <span class="p">..</span> <span class="n">S424</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Server_Error</span> <span class="kr">is</span> <span class="n">Status_Code</span> <span class="kr">range</span> <span class="n">S500</span> <span class="p">..</span> <span class="n">S507</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">S</span> <span class="p">: </span><span class="nv">Status_Code</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns Status_Code image. This value does not contain the leading S</span>
<span class="kd">function</span> <span class="nf">Reason_Phrase</span> <span class="p">(</span><span class="nv">S</span> <span class="p">: </span><span class="nv">Status_Code</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the reason phrase for the status code S, see [RFC 2616 - 6.1.1]</span>
<span class="c1">----------------------</span>
<span class="c1">-- Content encoding --</span>
<span class="c1">----------------------</span>
<span class="kd">type</span> <span class="kt">Content_Encoding</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Identity</span><span class="p">,</span> <span class="nv">GZip</span><span class="p">,</span> <span class="nv">Deflate</span><span class="p">);</span>
<span class="c1">-- Encoding mode for the response, Identity means that no encoding is</span>
<span class="c1">-- done, Gzip/Deflate to select the Gzip or Deflate encoding algorithm.</span>
<span class="c1">-------------------</span>
<span class="c1">-- Cache_Control --</span>
<span class="c1">-------------------</span>
<span class="kd">type</span> <span class="kt">Cache_Option</span> <span class="kr">is</span> <span class="kr">new</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Cache_Option is a string and any specific option can be specified. We</span>
<span class="c1">-- define four options:</span>
<span class="c1">--</span>
<span class="c1">-- Unspecified : No cache option will used.</span>
<span class="c1">-- No_Cache : Ask browser and proxy to not cache data (no-cache,</span>
<span class="c1">-- max-age, and s-maxage are specified).</span>
<span class="c1">-- No_Store : Ask browser and proxy to not store any data. This can be</span>
<span class="c1">-- used to protect sensitive data.</span>
<span class="c1">-- Prevent_Cache : Equivalent to No_Store + No_Cache</span>
<span class="no">Unspecified</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Cache_Option</span><span class="p">;</span>
<span class="no">No_Cache</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Cache_Option</span><span class="p">;</span>
<span class="no">No_Store</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Cache_Option</span><span class="p">;</span>
<span class="no">Prevent_Cache</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Cache_Option</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Cache_Kind</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Request</span><span class="p">,</span> <span class="nv">Response</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Delta_Seconds</span> <span class="kr">is</span> <span class="kr">new</span> <span class="kt">Integer</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">1</span> <span class="p">..</span> <span class="kt">Integer</span><span class="p">'</span><span class="na">Last</span><span class="p">;</span>
<span class="c1">-- Represents a delta-seconds parameter for some Cache_Data fields like</span>
<span class="c1">-- max-age, max-stale (value -1 is used for Unset).</span>
<span class="no">Unset</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Delta_Seconds</span><span class="p">;</span>
<span class="no">No_Max_Stale</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Delta_Seconds</span><span class="p">;</span>
<span class="no">Any_Max_Stale</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Delta_Seconds</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Private_Option</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="no">All_Private</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kd">Private</span><span class="mi">_</span><span class="n">Option</span><span class="p">;</span>
<span class="kd">Private</span><span class="no">_Unset</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kd">Private</span><span class="mi">_</span><span class="n">Option</span><span class="p">;</span>
<span class="c1">-- Cache_Data is a record that represents cache control information</span>
<span class="kd">type</span> <span class="kt">Cache_Data</span> <span class="p">(</span><span class="nv">CKind</span> <span class="p">: </span><span class="nv">Cache_Kind</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">No_Cache</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="n">No_Store</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="n">No_Transform</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="n">Max_Age</span> <span class="p">:</span> <span class="n">Delta_Seconds</span> <span class="p">:=</span> <span class="n">Unset</span><span class="p">;</span>
<span class="kr">case</span> <span class="n">CKind</span> <span class="kr">is</span>
<span class="kr">when</span> <span class="n">Request</span> <span class="p">=></span>
<span class="n">Max_Stale</span> <span class="p">:</span> <span class="n">Delta_Seconds</span> <span class="p">:=</span> <span class="n">Unset</span><span class="p">;</span>
<span class="n">Min_Fresh</span> <span class="p">:</span> <span class="n">Delta_Seconds</span> <span class="p">:=</span> <span class="n">Unset</span><span class="p">;</span>
<span class="n">Only_If_Cached</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="kr">when</span> <span class="n">Response</span> <span class="p">=></span>
<span class="n">S_Max_Age</span> <span class="p">:</span> <span class="n">Delta_Seconds</span> <span class="p">:=</span> <span class="n">Unset</span><span class="p">;</span>
<span class="n">Public</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="kd">Private</span><span class="mi">_</span><span class="n">Field</span> <span class="p">:</span> <span class="kd">Private</span><span class="mi">_</span><span class="n">Option</span> <span class="p">:=</span> <span class="kd">Private</span><span class="mi">_</span><span class="n">Unset</span><span class="p">;</span>
<span class="n">Must_Revalidate</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="n">Proxy_Revalidate</span> <span class="p">:</span> <span class="kt">Boolean</span> <span class="p">:=</span> <span class="kc">False</span><span class="p">;</span>
<span class="kr">end</span> <span class="kr">case</span><span class="p">;</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">To_Cache_Option</span> <span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Cache_Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Cache_Option</span><span class="p">;</span>
<span class="c1">-- Returns a cache control value for an HTTP request/response, fields are</span>
<span class="c1">-- described into RFC 2616 [14.9 Cache-Control].</span>
<span class="kd">function</span> <span class="nf">To_Cache_Data</span>
<span class="p">(</span><span class="nv">Kind</span> <span class="p">: </span><span class="nv">Cache_Kind</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Cache_Option</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Cache_Data</span><span class="p">;</span>
<span class="c1">-- Returns a Cache_Data record parsed out of Cache_Option</span>
<span class="c1">----------</span>
<span class="c1">-- ETag --</span>
<span class="c1">----------</span>
<span class="kd">type</span> <span class="kt">ETag_Value</span> <span class="kr">is</span> <span class="kr">new</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Create_ETag</span>
<span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Weak</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="n">ETag_Value</span><span class="p">;</span>
<span class="c1">-- Returns an ETag value (strong by default and Weak if specified). For a</span>
<span class="c1">-- discussion about ETag see RFC 2616 [3.11 Entity Tags] and [14.19 ETag].</span>
<span class="c1">-------------------------------</span>
<span class="c1">-- HTTP message constructors --</span>
<span class="c1">-------------------------------</span>
<span class="kd">function</span> <span class="nf">Accept_Encoding</span> <span class="p">(</span><span class="nv">Encoding</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Accept_Type</span> <span class="p">(</span><span class="nv">Mode</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Accept_Language</span> <span class="p">(</span><span class="nv">Mode</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Authorization</span> <span class="p">(</span><span class="nv">Mode</span><span class="p">,</span> <span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Connection</span> <span class="p">(</span><span class="nv">Mode</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Content_Length</span> <span class="p">(</span><span class="nv">Size</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Cookie</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Content_Type</span>
<span class="p">(</span><span class="nv">Format</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Boundary</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Cache_Control</span> <span class="p">(</span><span class="nv">Option</span> <span class="p">: </span><span class="nv">Cache_Option</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Cache_Control</span> <span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Cache_Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Content_Disposition</span>
<span class="p">(</span><span class="nv">Format</span><span class="p">,</span> <span class="nv">Name</span><span class="p">,</span> <span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Note that this is not part of HTTP/1.1 standard, it is there because</span>
<span class="c1">-- there is a lot of implementation around using it. This header is used</span>
<span class="c1">-- in multipart data.</span>
<span class="kd">function</span> <span class="nf">ETag</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">ETag_Value</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Expires</span> <span class="p">(</span><span class="nv">Date</span> <span class="p">: </span><span class="nv">Calendar</span><span class="p">.</span><span class="nv">Time</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- The date should not be more than a year in the future, see RFC 2616</span>
<span class="c1">-- [14.21 Expires].</span>
<span class="kd">function</span> <span class="nf">Host</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Last_Modified</span> <span class="p">(</span><span class="nv">Date</span> <span class="p">: </span><span class="nv">Calendar</span><span class="p">.</span><span class="nv">Time</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Location</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Proxy_Authorization</span> <span class="p">(</span><span class="nv">Mode</span><span class="p">,</span> <span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Proxy_Connection</span> <span class="p">(</span><span class="nv">Mode</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Data_Range</span> <span class="p">(</span><span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">SOAPAction</span> <span class="p">(</span><span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Status_Line</span>
<span class="p">(</span><span class="nv">Code</span> <span class="p">: </span><span class="nv">Status_Code</span><span class="p">;</span>
<span class="nv">Reason_Phrase</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Transfer_Encoding</span> <span class="p">(</span><span class="nv">Encoding</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">User_Agent</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">WWW_Authenticate</span> <span class="p">(</span><span class="nv">Realm</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Basic authentication request</span>
<span class="kd">function</span> <span class="nf">WWW_Authenticate</span>
<span class="p">(</span><span class="nv">Realm</span><span class="p">,</span> <span class="nv">Nonce</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Stale</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Digest authentication request</span>
<span class="kd">function</span> <span class="nf">Sec_WebSocket_Accept</span> <span class="p">(</span><span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-----------------------</span>
<span class="c1">-- helper functions --</span>
<span class="c1">-----------------------</span>
<span class="kd">function</span> <span class="nf">To_HTTP_Date</span> <span class="p">(</span><span class="nv">Time</span> <span class="p">: </span><span class="nv">Calendar</span><span class="p">.</span><span class="nv">Time</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns an Ada time as a string using the HTTP normalized format.</span>
<span class="c1">-- Format is RFC 822, updated by RFC 1123.</span>
<span class="kd">function</span> <span class="nf">To_Time</span> <span class="p">(</span><span class="nv">HTTP_Date</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="c1">-- Returns an Ada time from an HTTP one. This is To_HTTP_Date opposite</span>
<span class="c1">-- function.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Messages</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-mime">
<span id="id23"></span><h2>13.23. AWS.MIME<a class="headerlink" href="#aws-mime" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-25"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">AWS.MIME</span> <span class="kr">is</span>
<span class="c1">-- Some content type constants. All of them will be defined into this</span>
<span class="c1">-- package and associated with the right extensions. It is possible to</span>
<span class="c1">-- add new MIME types with the routines below or by placing a file named</span>
<span class="c1">-- aws.mime into the startup directory.</span>
<span class="c1">--</span>
<span class="c1">-- A MIME type is written in two parts: type/format</span>
<span class="c1">----------</span>
<span class="c1">-- Text --</span>
<span class="c1">----------</span>
<span class="no">Text_CSS</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"text/css"</span><span class="p">;</span>
<span class="no">Text_Javascript</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"text/javascript"</span><span class="p">;</span>
<span class="no">Text_HTML</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"text/html"</span><span class="p">;</span>
<span class="no">Text_Plain</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"text/plain"</span><span class="p">;</span>
<span class="no">Text_XML</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"text/xml"</span><span class="p">;</span>
<span class="no">Text_X_SGML</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"text/x-sgml"</span><span class="p">;</span>
<span class="c1">-----------</span>
<span class="c1">-- Image --</span>
<span class="c1">-----------</span>
<span class="no">Image_Gif</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/gif"</span><span class="p">;</span>
<span class="no">Image_Jpeg</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/jpeg"</span><span class="p">;</span>
<span class="no">Image_Png</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/png"</span><span class="p">;</span>
<span class="no">Image_SVG</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/svg+xml"</span><span class="p">;</span>
<span class="no">Image_Tiff</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/tiff"</span><span class="p">;</span>
<span class="no">Image_Icon</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-icon"</span><span class="p">;</span>
<span class="no">Image_X_Portable_Anymap</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-portable-anymap"</span><span class="p">;</span>
<span class="no">Image_X_Portable_Bitmap</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-portable-bitmap"</span><span class="p">;</span>
<span class="no">Image_X_Portable_Graymap</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-portable-graymap"</span><span class="p">;</span>
<span class="no">Image_X_Portable_Pixmap</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-portable-pixmap"</span><span class="p">;</span>
<span class="no">Image_X_RGB</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-rgb"</span><span class="p">;</span>
<span class="no">Image_X_Xbitmap</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-xbitmap"</span><span class="p">;</span>
<span class="no">Image_X_Xpixmap</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-xpixmap"</span><span class="p">;</span>
<span class="no">Image_X_Xwindowdump</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"image/x-xwindowdump"</span><span class="p">;</span>
<span class="c1">-----------------</span>
<span class="c1">-- Application --</span>
<span class="c1">-----------------</span>
<span class="no">Application_Postscript</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/postscript"</span><span class="p">;</span>
<span class="no">Application_Pdf</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/pdf"</span><span class="p">;</span>
<span class="no">Application_Zip</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/zip"</span><span class="p">;</span>
<span class="no">Application_Octet_Stream</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/octet-stream"</span><span class="p">;</span>
<span class="no">Application_Form_Data</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"application/x-www-form-urlencoded"</span><span class="p">;</span>
<span class="no">Application_Mac_Binhex40</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/mac-binhex40"</span><span class="p">;</span>
<span class="no">Application_Msword</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/msword"</span><span class="p">;</span>
<span class="no">Application_Powerpoint</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/powerpoint"</span><span class="p">;</span>
<span class="no">Application_Rtf</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/rtf"</span><span class="p">;</span>
<span class="no">Application_XML</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/xml"</span><span class="p">;</span>
<span class="no">Application_JSON</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/json"</span><span class="p">;</span>
<span class="no">Application_SOAP</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/soap"</span><span class="p">;</span>
<span class="no">Application_X_Compress</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-compress"</span><span class="p">;</span>
<span class="no">Application_X_GTar</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-gtar"</span><span class="p">;</span>
<span class="no">Application_X_GZip</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-gzip"</span><span class="p">;</span>
<span class="no">Application_X_Latex</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-latex"</span><span class="p">;</span>
<span class="no">Application_X_Sh</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-sh"</span><span class="p">;</span>
<span class="no">Application_X_Shar</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-shar"</span><span class="p">;</span>
<span class="no">Application_X_Tar</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-tar"</span><span class="p">;</span>
<span class="no">Application_X_Tcl</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-tcl"</span><span class="p">;</span>
<span class="no">Application_X_Tex</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-tex"</span><span class="p">;</span>
<span class="no">Application_X_Texinfo</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-texinfo"</span><span class="p">;</span>
<span class="no">Application_X_Troff</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-troff"</span><span class="p">;</span>
<span class="no">Application_X_Troff_Man</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"application/x-troff-man"</span><span class="p">;</span>
<span class="c1">-----------</span>
<span class="c1">-- Audio --</span>
<span class="c1">-----------</span>
<span class="no">Audio_Basic</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"audio/basic"</span><span class="p">;</span>
<span class="no">Audio_Mpeg</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"audio/mpeg"</span><span class="p">;</span>
<span class="no">Audio_X_Wav</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"audio/x-wav"</span><span class="p">;</span>
<span class="no">Audio_X_Pn_Realaudio</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"audio/x-pn-realaudio"</span><span class="p">;</span>
<span class="no">Audio_X_Pn_Realaudio_Plugin</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"audio/x-pn-realaudio-plugin"</span><span class="p">;</span>
<span class="no">Audio_X_Realaudio</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"audio/x-realaudio"</span><span class="p">;</span>
<span class="c1">-----------</span>
<span class="c1">-- Video --</span>
<span class="c1">-----------</span>
<span class="no">Video_Mpeg</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"video/mpeg"</span><span class="p">;</span>
<span class="no">Video_Quicktime</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"video/quicktime"</span><span class="p">;</span>
<span class="no">Video_X_Msvideo</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"video/x-msvideo"</span><span class="p">;</span>
<span class="c1">---------------</span>
<span class="c1">-- Multipart --</span>
<span class="c1">---------------</span>
<span class="no">Multipart_Form_Data</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"multipart/form-data"</span><span class="p">;</span>
<span class="no">Multipart_Byteranges</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"multipart/byteranges"</span><span class="p">;</span>
<span class="no">Multipart_Related</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"multipart/related"</span><span class="p">;</span>
<span class="no">Multipart_X_Mixed_Replace</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span>
<span class="s">"multipart/x-mixed-replace"</span><span class="p">;</span>
<span class="c1">-------------</span>
<span class="c1">-- Setting --</span>
<span class="c1">-------------</span>
<span class="kd">procedure</span> <span class="nf">Add_Extension</span> <span class="p">(</span><span class="nv">Ext</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Add extension Ext (file extension without the dot, e.g. "txt") to the</span>
<span class="c1">-- set of MIME type extension handled by this API. Ext will be mapped to</span>
<span class="c1">-- the MIME_Type string.</span>
<span class="kd">procedure</span> <span class="nf">Add_Regexp</span> <span class="p">(</span><span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Add a specific rule to the MIME type table. Filename is a regular</span>
<span class="c1">-- expression and will be mapped to the MIME_Type string.</span>
<span class="c1">---------------</span>
<span class="c1">-- MIME Type --</span>
<span class="c1">---------------</span>
<span class="kd">function</span> <span class="nf">Content_Type</span>
<span class="p">(</span><span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Default</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Application_Octet_Stream</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the MIME Content Type based on filename's extension or if not</span>
<span class="c1">-- found the MIME Content type where Filename matches one of the specific</span>
<span class="c1">-- rules set by Add_Regexp (see below).</span>
<span class="c1">-- Returns Default if the file type is unknown (i.e. no extension and</span>
<span class="c1">-- no regular expression match filename).</span>
<span class="kd">function</span> <span class="nf">Extension</span> <span class="p">(</span><span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the best guess of the extension to use for the Content Type.</span>
<span class="c1">-- Note that extensions added indirectly by Add_Regexp are not searched.</span>
<span class="kd">function</span> <span class="nf">Is_Text</span> <span class="p">(</span><span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the MIME_Type is a text data</span>
<span class="kd">function</span> <span class="nf">Is_Audio</span> <span class="p">(</span><span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the MIME_Type is an audio data</span>
<span class="kd">function</span> <span class="nf">Is_Image</span> <span class="p">(</span><span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the MIME_Type is an image data</span>
<span class="kd">function</span> <span class="nf">Is_Video</span> <span class="p">(</span><span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the MIME_Type is a video data</span>
<span class="kd">function</span> <span class="nf">Is_Application</span> <span class="p">(</span><span class="nv">MIME_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the MIME_Type is an application data</span>
<span class="kd">procedure</span> <span class="nf">Load</span> <span class="p">(</span><span class="nv">MIME_File</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Load MIME_File, record every MIME type. Note that the format of this</span>
<span class="c1">-- file follows the common standard format used by Apache mime.types.</span>
<span class="kr">end</span> <span class="nf">AWS.MIME</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net">
<span id="id24"></span><h2>13.24. AWS.Net<a class="headerlink" href="#aws-net" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-26"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- There is two implementations for this spec. One for standard sockets and</span>
<span class="c1">-- one for SSL socket. Note that the SSL implementation does support standard</span>
<span class="c1">-- socket too, this is controlled with the Security boolean on rountine</span>
<span class="c1">-- below. The corresponding implementation will be selected at build time.</span>
<span class="kn">with</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Interfaces.C</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Net</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="n">Socket_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised by all routines below, a message will indicate the nature of</span>
<span class="c1">-- the error.</span>
<span class="kd">type</span> <span class="kt">Socket_Type</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">new</span> <span class="n">Finalization</span><span class="p">.</span><span class="kt">Controlled</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Socket_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Socket_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Socket_Access</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">FD_Type</span> <span class="kr">is</span> <span class="kt">Integer</span><span class="p">;</span>
<span class="c1">-- Represents an external socket file descriptor</span>
<span class="no">No_Socket</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="c1">-- Represents closed socket file descriptor</span>
<span class="kd">type</span> <span class="kt">FD_Set</span> <span class="p">(</span><span class="nv">Size</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Abstract type for waiting of network events on group of sockets FD</span>
<span class="kd">type</span> <span class="kt">Event_Type</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Error</span><span class="p">,</span> <span class="nv">Input</span><span class="p">,</span> <span class="nv">Output</span><span class="p">);</span>
<span class="c1">-- Error - socket is in error state.</span>
<span class="c1">-- Input - socket ready for read.</span>
<span class="c1">-- Output - socket available for write.</span>
<span class="kd">type</span> <span class="kt">Event_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="n">Event_Type</span><span class="p">)</span> <span class="kr">of</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Type for get result of events waiting</span>
<span class="kd">subtype</span> <span class="kt">Wait_Event_Type</span> <span class="kr">is</span> <span class="n">Event_Type</span> <span class="kr">range</span> <span class="n">Input</span> <span class="p">..</span> <span class="n">Output</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Wait_Event_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="n">Wait_Event_Type</span><span class="p">)</span> <span class="kr">of</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Type for set events to wait, note that Error event would be waited</span>
<span class="c1">-- anyway.</span>
<span class="kd">type</span> <span class="kt">Family_Type</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Family_Inet</span><span class="p">,</span> <span class="nv">Family_Inet6</span><span class="p">,</span> <span class="nv">Family_Unspec</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Shutmode_Type</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Shut_Read</span><span class="p">,</span> <span class="nv">Shut_Write</span><span class="p">,</span> <span class="nv">Shut_Read_Write</span><span class="p">);</span>
<span class="no">Forever</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">Duration</span><span class="p">;</span>
<span class="c1">-- The longest delay possible on the implementation</span>
<span class="c1">----------------</span>
<span class="c1">-- Initialize --</span>
<span class="c1">----------------</span>
<span class="kd">function</span> <span class="nf">Socket</span> <span class="p">(</span><span class="nv">Security</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Create an uninitialized socket</span>
<span class="kd">function</span> <span class="nf">Socket</span>
<span class="p">(</span><span class="nv">Security</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span> <span class="n">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Create a dynamically allocated uninitialized socket</span>
<span class="kd">procedure</span> <span class="nf">Bind</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">;</span>
<span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Reuse_Address</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Family</span> <span class="p">: </span><span class="nv">Family_Type</span> <span class="p">:=</span> <span class="nv">Family_Unspec</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Create the server socket and bind it on the given port.</span>
<span class="c1">-- Using 0 for the port will tell the OS to allocate a non-privileged</span>
<span class="c1">-- free port. The port can be later retrieved using Get_Port on the</span>
<span class="c1">-- bound socket.</span>
<span class="kd">procedure</span> <span class="nf">Listen</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span> <span class="nv">Queue_Size</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">5</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Set the queue size of the socket</span>
<span class="kd">procedure</span> <span class="nf">Accept_Socket</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">New_Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Accept a connection on a socket. If it raises Socket_Error, all</span>
<span class="c1">-- resources used by new_Socket have been released.</span>
<span class="c1">-- There is not need to call Free or Shutdown.</span>
<span class="kd">type</span> <span class="kt">Socket_Constructor</span> <span class="kr">is</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span>
<span class="kd">function</span> <span class="p">(</span><span class="nv">Security</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Connect</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Wait</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Family</span> <span class="p">: </span><span class="nv">Family_Type</span> <span class="p">:=</span> <span class="nv">Family_Unspec</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Host</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Connect a socket on a given host/port. If Wait is True Connect will wait</span>
<span class="c1">-- for the connection to be established for timeout seconds, specified by</span>
<span class="c1">-- Set_Timeout routine. If Wait is False Connect will return immediately,</span>
<span class="c1">-- not waiting for the connection to be establised. It is possible to wait</span>
<span class="c1">-- for the Connection completion by calling Wait routine with Output set to</span>
<span class="c1">-- True in Events parameter.</span>
<span class="kd">procedure</span> <span class="nf">Socket_Pair</span> <span class="p">(</span><span class="nv">S1</span><span class="p">,</span> <span class="nv">S2</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">);</span>
<span class="c1">-- Create 2 sockets and connect them together</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">How</span> <span class="p">: </span><span class="nv">Shutmode_Type</span> <span class="p">:=</span> <span class="nv">Shut_Read_Write</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Shutdown the read, write or both side of the socket.</span>
<span class="c1">-- If How is Both, close it. Does not raise Socket_Error if the socket is</span>
<span class="c1">-- not connected or already shutdown.</span>
<span class="kd">procedure</span> <span class="nf">Free</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Access</span><span class="p">);</span>
<span class="c1">-- Release memory associated with the socket</span>
<span class="c1">--------</span>
<span class="c1">-- IO --</span>
<span class="c1">--------</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">);</span>
<span class="c1">-- Send Data chunk to the socket</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Sockets</span> <span class="p">: </span><span class="nv">Socket_Set</span><span class="p">;</span> <span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">);</span>
<span class="c1">-- Send Data to all sockets from the socket set. This call will ensure that</span>
<span class="c1">-- the data are sent in priority to client waiting for reading. That is,</span>
<span class="c1">-- slow connection for one sokcet should not delay the fast connections.</span>
<span class="c1">-- Yet, this routine will return only when the data is sent to all sockets.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Try to place data to Socket's output buffer. If all data cannot be</span>
<span class="c1">-- placed to the socket output buffer, Last will be lower than Data'Last,</span>
<span class="c1">-- if no data has been placed into the output buffer, Last is set to</span>
<span class="c1">-- Data'First - 1. If Data'First is equal to Stream_Element_Offset'First</span>
<span class="c1">-- then constraint error is raised to follow advice in AI95-227.</span>
<span class="kd">procedure</span> <span class="nf">Receive</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Read a chunk of data from the socket and set appropriate Last value.</span>
<span class="c1">-- This call always returns some data and will wait for incoming data only</span>
<span class="c1">-- if necessary.</span>
<span class="kd">function</span> <span class="nf">Receive</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Max</span> <span class="p">: </span><span class="nv">Stream_Element_Count</span> <span class="p">:=</span> <span class="nv">4096</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span><span class="p">;</span>
<span class="c1">-- Read a chunk of data from the socket and returns it. This call always</span>
<span class="c1">-- returns some data and will wait for incoming data only if necessary.</span>
<span class="kd">function</span> <span class="nf">Pending</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Count</span>
<span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the number of bytes which are available inside socket</span>
<span class="c1">-- for immediate read.</span>
<span class="kd">function</span> <span class="nf">Output_Space</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="c1">-- Returns the free space in output buffer in bytes. If OS could not</span>
<span class="c1">-- provide such information, routine returns -1.</span>
<span class="kd">function</span> <span class="nf">Output_Busy</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="c1">-- How many bytes in the send queue. If OS could not provide such</span>
<span class="c1">-- information, routine returns -1.</span>
<span class="c1">------------</span>
<span class="c1">-- Others --</span>
<span class="c1">------------</span>
<span class="kd">function</span> <span class="nf">Get_FD</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">FD_Type</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the file descriptor associated with the socket</span>
<span class="kd">function</span> <span class="nf">Peer_Addr</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the peer name/address</span>
<span class="kd">function</span> <span class="nf">Peer_Port</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the port of the peer socket</span>
<span class="kd">function</span> <span class="nf">Get_Addr</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the name/address of the socket</span>
<span class="kd">function</span> <span class="nf">Get_Port</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the port of the socket</span>
<span class="kd">function</span> <span class="nf">Is_Any_Address</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Return true if the socket accepts connections on any of the hosts's</span>
<span class="c1">-- network addresses.</span>
<span class="kd">function</span> <span class="nf">Is_IPv6</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Is_Listening</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns true if the socket has been marked to accept connections with</span>
<span class="c1">-- listen.</span>
<span class="kd">function</span> <span class="nf">IPv6_Available</span> <span class="nf">return</span> <span class="nf">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if IPv6 available in OS and in AWS socket implementation</span>
<span class="kd">function</span> <span class="nf">Host_Name</span> <span class="nf">return</span> <span class="nf">String</span><span class="p">;</span>
<span class="c1">-- Returns the running host name</span>
<span class="kd">procedure</span> <span class="nf">Set_Send_Buffer_Size</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span> <span class="nv">Size</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Set the internal socket send buffer size.</span>
<span class="c1">-- Do not confuse with buffers for the AWS.Net.Buffered operations.</span>
<span class="kd">procedure</span> <span class="nf">Set_Receive_Buffer_Size</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span> <span class="nv">Size</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Set the internal socket receive buffer size.</span>
<span class="c1">-- Do not confuse with buffers for the AWS.Net.Buffered operations.</span>
<span class="kd">function</span> <span class="nf">Get_Send_Buffer_Size</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span>
<span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the internal socket send buffer size.</span>
<span class="c1">-- Do not confuse with buffers for the AWS.Net.Buffered operations.</span>
<span class="kd">function</span> <span class="nf">Get_Receive_Buffer_Size</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span>
<span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns the internal socket receive buffer size.</span>
<span class="c1">-- Do not confuse with buffers for the AWS.Net.Buffered operations.</span>
<span class="kd">function</span> <span class="nf">Cipher_Description</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns cipher description on SSL implementation or empty string on</span>
<span class="c1">-- plain socket.</span>
<span class="kd">procedure</span> <span class="nf">Set_Blocking_Mode</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">;</span> <span class="nv">Blocking</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="kr">pragma</span> <span class="cp">Obsolescent</span> <span class="p">(</span><span class="s">"Use Set_Timeout instead"</span><span class="p">);</span>
<span class="c1">-- Set the blocking mode for the socket</span>
<span class="kd">procedure</span> <span class="nf">Set_Timeout</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">;</span> <span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Sets the timeout for the socket read/write operations</span>
<span class="kd">procedure</span> <span class="nf">Set_No_Delay</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- Set/clear TCP_NODELAY option on socket</span>
<span class="kd">function</span> <span class="nf">Wait</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Events</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Event_Set</span><span class="p">;</span>
<span class="c1">-- Waiting for Input/Output/Error events.</span>
<span class="c1">-- Waiting time is defined by Set_Timeout.</span>
<span class="c1">-- Empty event set in result mean that timeout occured.</span>
<span class="kd">function</span> <span class="nf">Check</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Events</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Event_Set</span><span class="p">;</span>
<span class="c1">-- Check for Input/Output/Error events availability.</span>
<span class="c1">-- No wait for socket timeout.</span>
<span class="kd">function</span> <span class="nf">Poll</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Events</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Event_Set</span><span class="p">;</span>
<span class="c1">-- Wait events on socket descriptor for specified Timeout</span>
<span class="kd">function</span> <span class="nf">Errno</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns and clears error state in socket</span>
<span class="kd">function</span> <span class="nf">Is_Timeout</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">E</span> <span class="p">: </span><span class="nv">Exception_Occurrence</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the message associated with the Exception_Occurence for</span>
<span class="c1">-- a Socket_Error is a timeout.</span>
<span class="kd">function</span> <span class="nf">Is_Timeout</span> <span class="p">(</span><span class="nv">E</span> <span class="p">: </span><span class="nv">Exception_Occurrence</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- As above but without Socket parameter</span>
<span class="kd">function</span> <span class="nf">Is_Peer_Closed</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">E</span> <span class="p">: </span><span class="nv">Exception_Occurrence</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the message associated with the Exception_Occurence for</span>
<span class="c1">-- a Socket_Error is a "socket closed by peer".</span>
<span class="kd">function</span> <span class="nf">To_FD_Set</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">;</span>
<span class="nv">Events</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">;</span>
<span class="nv">Size</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="n">FD_Set</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Create appropriate socket FD set and put Socket fd there</span>
<span class="c1">--------------------</span>
<span class="c1">-- Socket FD sets --</span>
<span class="c1">--------------------</span>
<span class="kd">type</span> <span class="kt">FD_Set_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">FD_Set</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">FD_Set_Access</span><span class="p">;</span>
<span class="nv">FD</span> <span class="p">: </span><span class="nv">FD_Type</span><span class="p">;</span>
<span class="nv">Event</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">);</span>
<span class="c1">-- Add FD to the end of FD_Set</span>
<span class="kd">procedure</span> <span class="nf">Free</span> <span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">FD_Set_Access</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Deallocate the socket FD set</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">FD</span> <span class="p">: </span><span class="nv">FD_Type</span><span class="p">;</span>
<span class="nv">Event</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Add FD to the end of FD_Set</span>
<span class="kd">procedure</span> <span class="nf">Replace</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">FD</span> <span class="p">: </span><span class="nv">FD_Type</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">);</span>
<span class="c1">-- Replaces the socket FD in FD_Set</span>
<span class="kd">procedure</span> <span class="nf">Set_Mode</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Wait_Event_Set</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">);</span>
<span class="c1">-- Sets the kind of network events to wait for</span>
<span class="kd">procedure</span> <span class="nf">Set_Event</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Event</span> <span class="p">: </span><span class="nv">Wait_Event_Type</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Copy</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">Size</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">return</span> <span class="n">FD_Set_Access</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Allocates and copy the given FD_Set with different size</span>
<span class="kd">procedure</span> <span class="nf">Remove</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span> <span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">);</span>
<span class="c1">-- Removes socket FD from Index position.</span>
<span class="c1">-- Last socket FD in FD_Set is placed at position Index.</span>
<span class="kd">function</span> <span class="nf">Length</span> <span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Returns number of socket FD elements in FD_Set</span>
<span class="kd">procedure</span> <span class="nf">Wait</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">;</span>
<span class="nv">Count</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Post</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="kt">Count</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">);</span>
<span class="c1">-- Wait for network events on the sockets FD set. Count value is the</span>
<span class="c1">-- number of socket FDs with non empty event set.</span>
<span class="kd">procedure</span> <span class="nf">Next</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span> <span class="nv">Index</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Positive</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span>
<span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span>
<span class="n">Post</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">-- Looking for an active (for which an event has been detected by routine</span>
<span class="c1">-- Wait above) socket FD starting from Index and return Index of the found</span>
<span class="c1">-- active socket FD. Use functions Status to retreive the kind of network</span>
<span class="c1">-- events for this socket.</span>
<span class="kd">function</span> <span class="nf">Status</span>
<span class="p">(</span><span class="nv">FD_Set</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">FD_Set</span><span class="p">;</span>
<span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Event_Set</span> <span class="kr">is</span> <span class="kr">abstract</span>
<span class="kn">with</span> <span class="nn">Pre</span><span class="p">'</span><span class="na">Class</span> <span class="p">=></span> <span class="n">Index</span> <span class="o"><=</span> <span class="n">Length</span> <span class="p">(</span><span class="n">FD_Set</span><span class="p">);</span>
<span class="c1">-- Returns events for the socket FD at position Index</span>
<span class="kd">procedure</span> <span class="nf">Free</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- Release memory associated with the socket object. This default version</span>
<span class="c1">-- can be overriden to properly release the memory for the derived</span>
<span class="c1">-- implementation. The controlled Finalize routine is in charge of calling</span>
<span class="c1">-- Free. We could not have it in the private part because we could not make</span>
<span class="c1">-- AWS.Net.SSL.Free overriding this way.</span>
<span class="kd">function</span> <span class="nf">Localhost</span> <span class="p">(</span><span class="nv">IPv6</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns "::1" if IPv6 is true or "127.0.0.1" otherwise</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Net</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-buffered">
<span id="id25"></span><h2>13.25. AWS.Net.Buffered<a class="headerlink" href="#aws-net-buffered" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-27"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- All routines below are buffered both ways (input and output) for better</span>
<span class="c1">-- performances.</span>
<span class="kd">package</span> <span class="nc">AWS.Net.Buffered</span> <span class="kr">is</span>
<span class="c1">------------</span>
<span class="c1">-- Output --</span>
<span class="c1">------------</span>
<span class="kd">procedure</span> <span class="nf">Put</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Item</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Write Item into Socket's buffer. Send the buffer to the socket if full</span>
<span class="kd">procedure</span> <span class="nf">Put_Line</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Item</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Write Item & CRLF into Socket's buffer. Send the buffer to the socket</span>
<span class="c1">-- if full.</span>
<span class="kd">procedure</span> <span class="nf">New_Line</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Write CRLF into Socket's buffer. Send the buffer to the socket if full</span>
<span class="kd">procedure</span> <span class="nf">Write</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Item</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">);</span>
<span class="c1">-- Write Item into Socket's buffer. Send the buffer to the socket if full</span>
<span class="kd">procedure</span> <span class="nf">Flush</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Send the buffer to the socket</span>
<span class="c1">-----------</span>
<span class="c1">-- Input --</span>
<span class="c1">-----------</span>
<span class="n">Data_Overflow</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised from Get_Line and Read_Until routines when size of receiving data</span>
<span class="c1">-- exceeds the limit defined by Set_Input_Limit. It avoid unlimited dynamic</span>
<span class="c1">-- memory allocation inside of Get_Line and Read_Until when client trying</span>
<span class="c1">-- to attack the server by the very long lines in request. Moreover it</span>
<span class="c1">-- avoid stack overflow on very long data returned from Get_Line and</span>
<span class="c1">-- Read_Until.</span>
<span class="kd">procedure</span> <span class="nf">Set_Input_Limit</span> <span class="p">(</span><span class="nv">Limit</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Set the input size limit for Get_Line and Read_Until routines</span>
<span class="kd">function</span> <span class="nf">Get_Input_Limit</span> <span class="nf">return</span> <span class="nf">Stream_Element_Offset</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Get the input size limit for Get_Line and Read_Until routines</span>
<span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns Data array read from the socket</span>
<span class="kd">function</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Max</span> <span class="p">: </span><span class="nv">Stream_Element_Count</span> <span class="p">:=</span> <span class="nv">4096</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns an array of bytes read from the socket</span>
<span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Read any available data from buffered socket.</span>
<span class="c1">-- Wait if no data available.</span>
<span class="c1">-- Same semantic with Net.Receive procedure.</span>
<span class="kd">function</span> <span class="nf">Get_Line</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns a line read from Socket. A line is a set of character</span>
<span class="c1">-- terminated by CRLF.</span>
<span class="kd">function</span> <span class="nf">Get_Char</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Character</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns a single character read from socket</span>
<span class="kd">function</span> <span class="nf">Peek_Char</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Character</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns next character that will be read from Socket. It does not</span>
<span class="c1">-- actually consume the character, this character will be returned by</span>
<span class="c1">-- the next read operation on the socket.</span>
<span class="kd">procedure</span> <span class="nf">Read_Buffer</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Returns data read from the internal socket's read buffer. No data are</span>
<span class="c1">-- read from the socket. This can be useful when switching to non buffered</span>
<span class="c1">-- mode.</span>
<span class="kd">function</span> <span class="nf">Read_Until</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Delimiter</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Wait</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span><span class="p">;</span>
<span class="c1">-- Read data on the Socket until the delimiter (including the delimiter).</span>
<span class="c1">-- If Wait is False the routine looking for the delimiter only in the</span>
<span class="c1">-- cache buffer, if delimiter not found in the cache buffer, empty array</span>
<span class="c1">-- is be returned.</span>
<span class="c1">-- If returned data is without delimiter at the end, it means that socket</span>
<span class="c1">-- is closed from peer or socket error occured and rest of data returned.</span>
<span class="c1">-- This routine could loose some data on timeout if does not meet delimiter</span>
<span class="c1">-- longer then Read buffer size.</span>
<span class="kd">function</span> <span class="nf">Read_Until</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Delimiter</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Wait</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Same as above but returning a standard string</span>
<span class="c1">-------------</span>
<span class="c1">-- Control --</span>
<span class="c1">-------------</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Shutdown and close the socket. Release all memory and resources</span>
<span class="c1">-- associated with it.</span>
<span class="kr">end</span> <span class="nf">AWS.Net.Buffered</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-log">
<span id="id26"></span><h2>13.26. AWS.Net.Log<a class="headerlink" href="#aws-net-log" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-28"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package handles the Net logging facility for AWS.</span>
<span class="c1">--</span>
<span class="c1">-- AWS calls the Write procedure which in turn calls the callback routine</span>
<span class="c1">-- provided by the user when starting the logging. This feature can help</span>
<span class="c1">-- greatly to debug an application.</span>
<span class="c1">--</span>
<span class="c1">-- This package is thread safe. There will never be two simultaneous calls</span>
<span class="c1">-- to the callback routine.</span>
<span class="kd">package</span> <span class="nc">AWS.Net.Log</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Data_Direction</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Sent</span><span class="p">,</span> <span class="nv">Received</span><span class="p">);</span>
<span class="c1">-- The direction of the data, sent or received to/from the socket</span>
<span class="kd">type</span> <span class="kt">Event_Type</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Connect</span><span class="p">,</span> <span class="nv">Accept_Socket</span><span class="p">,</span> <span class="nv">Shutdown</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Write_Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span>
<span class="p">(</span><span class="nv">Direction</span> <span class="p">: </span><span class="nv">Data_Direction</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- The callback procedure which is called for each incoming/outgoing data</span>
<span class="kd">type</span> <span class="kt">Event_Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span>
<span class="p">(</span><span class="nv">Action</span> <span class="p">: </span><span class="nv">Event_Type</span><span class="p">;</span> <span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- The callback procedure which is called for every socket creation,</span>
<span class="c1">-- connect and accept.</span>
<span class="kd">type</span> <span class="kt">Error_Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- The callback procedure which is called for every socket error</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Write</span> <span class="p">: </span><span class="nv">Write_Callback</span><span class="p">;</span>
<span class="nv">Event</span> <span class="p">: </span><span class="nv">Event_Callback</span> <span class="p">:=</span> <span class="nv">null</span><span class="p">;</span>
<span class="nv">Error</span> <span class="p">: </span><span class="nv">Error_Callback</span> <span class="p">:=</span> <span class="nv">null</span><span class="p">);</span>
<span class="c1">-- Activate the logging</span>
<span class="kd">function</span> <span class="nf">Is_Active</span> <span class="nf">return</span> <span class="nf">Boolean</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if Log is activated and False otherwise</span>
<span class="kd">function</span> <span class="nf">Is_Write_Active</span> <span class="nf">return</span> <span class="nf">Boolean</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if Write Log is activated and False otherwise</span>
<span class="kd">function</span> <span class="nf">Is_Event_Active</span> <span class="nf">return</span> <span class="nf">Boolean</span> <span class="nf">with</span> <span class="nf">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if Event Log is activated and False otherwise</span>
<span class="kd">procedure</span> <span class="nf">Write</span>
<span class="p">(</span><span class="nv">Direction</span> <span class="p">: </span><span class="nv">Data_Direction</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Write sent/received data indirectly through the callback routine,</span>
<span class="c1">-- if activated (i.e. Start routine above has been called). Otherwise this</span>
<span class="c1">-- call does nothing.</span>
<span class="kd">procedure</span> <span class="nf">Event</span> <span class="p">(</span><span class="nv">Action</span> <span class="p">: </span><span class="nv">Event_Type</span><span class="p">;</span> <span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Call Event callback if activated (i.e. Start routine above has been</span>
<span class="c1">-- called). Otherwise this call does nothing.</span>
<span class="kd">procedure</span> <span class="nf">Error</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Call Error callback if activated (i.e. Start routine above has been</span>
<span class="c1">-- called). Otherwise this call does nothing.</span>
<span class="kd">procedure</span> <span class="nf">Stop</span><span class="p">;</span>
<span class="c1">-- Stop logging activity</span>
<span class="kr">end</span> <span class="nf">AWS.Net.Log</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-log-callbacks">
<span id="id27"></span><h2>13.27. AWS.Net.Log.Callbacks<a class="headerlink" href="#aws-net-log-callbacks" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-29"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Some ready to use write procedures</span>
<span class="kd">package</span> <span class="nc">AWS.Net.Log.Callbacks</span> <span class="kr">is</span>
<span class="kd">procedure</span> <span class="nf">Initialize</span>
<span class="p">(</span><span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Callback</span> <span class="p">: </span><span class="nv">Write_Callback</span><span class="p">);</span>
<span class="c1">-- Initialize the logging, must be called before using the callbacks below</span>
<span class="kd">procedure</span> <span class="nf">Finalize</span><span class="p">;</span>
<span class="c1">-- Stop logging, close log file</span>
<span class="kd">procedure</span> <span class="nf">Text</span>
<span class="p">(</span><span class="nv">Direction</span> <span class="p">: </span><span class="nv">Data_Direction</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- A text output, each chunk is output with an header and footer:</span>
<span class="c1">-- Data sent/received to/from socket <FD> (<size>/<buffer size>)</span>
<span class="c1">-- <data></span>
<span class="c1">-- Total data sent: <nnn> received: <nnn></span>
<span class="kd">procedure</span> <span class="nf">Binary</span>
<span class="p">(</span><span class="nv">Direction</span> <span class="p">: </span><span class="nv">Data_Direction</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- A binary output, each chunk is output with an header and footer. The</span>
<span class="c1">-- data itself is written using a format close to the Emacs hexl-mode:</span>
<span class="c1">-- Data sent/received to/from socket <FD> (<size>/<buffer size>)</span>
<span class="c1">-- HH HH HH HH HH HH HH HH HH HH HH HH az.rt.mpl..q</span>
<span class="c1">-- Total data sent: <nnn> received: <nnn></span>
<span class="c1">--</span>
<span class="c1">-- HH is the hex character number, if the character is not printable a dot</span>
<span class="c1">-- is written.</span>
<span class="kr">end</span> <span class="nf">AWS.Net.Log.Callbacks</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-ssl">
<span id="id28"></span><h2>13.28. AWS.Net.SSL<a class="headerlink" href="#aws-net-ssl" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-30"><div class="highlight"><pre><span></span>------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2002-2016, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
-- This is the SSL based implementation of the Net package. The implementation
-- should depend only on AWS.Net.Std and the SSL library. It is important to
-- not call directly a socket binding here to ease porting.
with Ada.Calendar;
with System;
with AWS.Net.Std;
with SSL.Thin;
package AWS.Net.SSL is
Socket_Error : exception renames Net.Socket_Error;
type Socket_Type is new Net.Std.Socket_Type with private;
type Session_Type is private;
-- To keep session data over plain socket reconnect
Null_Session : constant Session_Type;
Is_Supported : constant Boolean;
-- True if SSL supported in the current runtime
type Debug_Output_Procedure is access procedure (Text : String);
----------------
-- Initialize --
----------------
overriding procedure Accept_Socket
(Socket : Net.Socket_Type'Class; New_Socket : in out Socket_Type);
-- Accept a connection on a socket
overriding procedure Connect
(Socket : in out Socket_Type;
Host : String;
Port : Positive;
Wait : Boolean := True;
Family : Family_Type := Family_Unspec);
-- Connect a socket on a given host/port. If Wait is True Connect will wait
-- for the connection to be established for timeout seconds, specified by
-- Set_Timeout routine. If Wait is False Connect will return immediately,
-- not waiting for the connection to be establised and it does not make the
-- SSL handshake. It is possible to wait for the Connection completion by
-- calling Wait routine with Output set to True in Events parameter.
overriding procedure Socket_Pair (S1, S2 : out Socket_Type);
-- Create 2 sockets and connect them together
overriding procedure Shutdown
(Socket : Socket_Type; How : Shutmode_Type := Shut_Read_Write);
-- Shutdown the read, write or both side of the socket.
-- If How is Both, close it. Does not raise Socket_Error if the socket is
-- not connected or already shutdown.
--------
-- IO --
--------
overriding procedure Send
(Socket : Socket_Type;
Data : Stream_Element_Array;
Last : out Stream_Element_Offset);
overriding procedure Receive
(Socket : Socket_Type;
Data : out Stream_Element_Array;
Last : out Stream_Element_Offset)
with Inline;
overriding function Pending
(Socket : Socket_Type) return Stream_Element_Count;
-- Returns the number of bytes which are available inside socket
-- for immediate read.
--------------------
-- Initialization --
--------------------
type Method is
(SSLv23, SSLv23_Server, SSLv23_Client, -- Highest available SSL/TLS
TLSv1, TLSv1_Server, TLSv1_Client, -- TLS 1.0
TLSv1_1, TLSv1_1_Server, TLSv1_1_Client, -- TLS 1.1
TLSv1_2, TLSv1_2_Server, TLSv1_2_Client, -- TLS 1.2
SSLv3, SSLv3_Server, SSLv3_Client); -- SSLv3 (obsolescent)
pragma Obsolescent (SSLv3, "use SSLv23 instead");
pragma Obsolescent (SSLv3_Server, "use SSLv23_Server instead");
pragma Obsolescent (SSLv3_Client, "use SSLv23_Client instead");
type Config is private;
Null_Config : constant Config;
procedure Initialize
(Config : in out SSL.Config;
Certificate_Filename : String;
Security_Mode : Method := SSLv23;
Priorities : String := "";
Ticket_Support : Boolean := False;
Key_Filename : String := "";
Exchange_Certificate : Boolean := False;
Certificate_Required : Boolean := False;
Trusted_CA_Filename : String := "";
CRL_Filename : String := "";
Session_Cache_Size : Natural := 16#4000#);
-- Initialize the SSL layer into Config. Certificate_Filename must point
-- to a valid certificate. Security mode can be used to change the
-- security method used by AWS. Key_Filename must be specified if the key
-- is not in the same file as the certificate. The Config object can be
-- associated with all secure sockets sharing the same options. If
-- Exchange_Certificate is True the client will send its certificate to
-- the server, if False only the server will send its certificate.
procedure Add_Host_Certificate
(Config : SSL.Config;
Host : String;
Certificate_Filename : String;
Key_Filename : String := "");
-- Support for Server name indication (SNI). Client can ask for different
-- host names on the same IP address. This routines provide a way to have
-- different certificates for different server host names.
procedure Initialize_Default_Config
(Certificate_Filename : String;
Security_Mode : Method := SSLv23;
Priorities : String := "";
Ticket_Support : Boolean := False;
Key_Filename : String := "";
Exchange_Certificate : Boolean := False;
Certificate_Required : Boolean := False;
Trusted_CA_Filename : String := "";
CRL_Filename : String := "";
Session_Cache_Size : Natural := 16#4000#);
-- As above but for the default SSL configuration which is will be used
-- for any socket not setting explicitly an SSL config object. Not that
-- this routine can only be called once. Subsequent calls are no-op. To
-- be effective it must be called before any SSL socket is created.
procedure Release (Config : in out SSL.Config);
-- Release memory associated with the Config object
procedure Set_Config
(Socket : in out Socket_Type; Config : SSL.Config);
-- Set the SSL configuration object for the secure socket
function Get_Config (Socket : Socket_Type) return SSL.Config with Inline;
-- Get the SSL configuration object of the secure socket
function Secure_Client
(Socket : Net.Socket_Type'Class;
Config : SSL.Config := Null_Config) return Socket_Type;
-- Make client side SSL connection from plain socket.
-- SSL handshake does not performed. SSL handshake would be made
-- automatically on first Read/Write, or explicitly by the Do_Handshake
-- call. Do not free or close source socket after this call.
function Secure_Server
(Socket : Net.Socket_Type'Class;
Config : SSL.Config := Null_Config) return Socket_Type;
-- Make server side SSL connection from plain socket.
-- SSL handshake does not performed. SSL handshake would be made
-- automatically on first Read/Write, or explicitly by the Do_Handshake
-- call. Do not free or close source socket after this call.
procedure Do_Handshake (Socket : in out Socket_Type);
-- Wait for a SSL/TLS handshake to take place. You need to call this
-- routine if you have converted a standard socket to secure one and need
-- to get the peer certificate.
function Version (Build_Info : Boolean := False) return String;
-- Returns version information
procedure Clear_Session_Cache (Config : SSL.Config := Null_Config);
-- Remove all sessions from SSL session cache from the SSL context.
-- Null_Config mean default context.
procedure Set_Session_Cache_Size
(Size : Natural; Config : SSL.Config := Null_Config);
-- Set session cache size in the SSL context.
-- Null_Config mean default context.
function Session_Cache_Number
(Config : SSL.Config := Null_Config) return Natural;
-- Returns number of sessions currently in the cache.
-- Null_Config mean default context.
overriding function Cipher_Description (Socket : Socket_Type) return String;
procedure Ciphers (Cipher : not null access procedure (Name : String));
-- Calls callback Cipher for all available ciphers
procedure Generate_DH;
-- Regenerates Diffie-Hellman parameters.
-- The call could take a quite long time.
-- Diffie-Hellman parameters should be discarded and regenerated once a
-- week or once a month. Depends on the security requirements.
-- (gnutls/src/serv.c).
procedure Generate_RSA;
-- Regenerates RSA parameters.
-- The call could take some time.
-- RSA parameters should be discarded and regenerated once a day, once
-- every 500 transactions etc. Depends on the security requirements
-- (gnutls/src/serv.c).
procedure Abort_DH_Generation with Inline;
-- DH generation could be for a few minutes. If it is really necessary to
-- terminate process faster, this call should be used.
-- GNUTLS generates DH parameters much faster than OpenSSL, at least in
-- Linux x86_64 and does not support DH generation abort at least in
-- version 3.2.12.
procedure Start_Parameters_Generation
(DH : Boolean; Logging : access procedure (Text : String) := null)
with Inline;
-- Start SSL parameters regeneration in background.
-- DH is False mean only RSA parameters generated.
-- DH is True mean RSA and DH both parameters generated.
function Generated_Time_DH return Ada.Calendar.Time with Inline;
-- Returns date and time when the DH parameters was generated last time.
-- Need to decide when new regeneration would start.
function Generated_Time_RSA return Ada.Calendar.Time with Inline;
-- Returns date and time when the RSA parameters was generated last time.
-- Need to decide when new regeneration would start.
procedure Set_Debug
(Level : Natural; Output : Debug_Output_Procedure := null);
-- Set debug information printed level and output callback.
-- Null output callback mean output to Ada.Text_IO.Current_Error.
function Session_Id_Image (Session : Session_Type) return String;
-- Returns base64 encoded session id. Could be used to recognize resumed
-- session when it has the same Id.
function Session_Id_Image (Socket : Socket_Type) return String;
-- Returns base64 encoded session id of the socket
function Session_Data (Socket : Socket_Type) return Session_Type;
-- For the client side SSL socket returns session data to be used to
-- resume session after socket disconnected.
procedure Free (Session : in out Session_Type);
-- Free session data
procedure Set_Session_Data
(Socket : in out Socket_Type; Data : Session_Type);
-- For the client side SSL socket try to resume session from data taken
-- from previosly connected socket by Session_Data routine.
function Session_Reused (Socket : Socket_Type) return Boolean;
-- Returns True in case session was successfully reused after
-- Set_Session_Data and handshake.
type Private_Key is private;
Null_Private_Key : constant Private_Key;
type Hash_Method is (MD5, SHA1, SHA224, SHA256, SHA384, SHA512);
function Load (Filename : String) return Private_Key;
procedure Free (Key : in out Private_Key) with Inline;
function Signature
(Data : String;
Key : Private_Key;
Hash : Hash_Method) return Stream_Element_Array with Inline;
function Signature
(Data : Stream_Element_Array;
Key : Private_Key;
Hash : Hash_Method) return Stream_Element_Array with Inline;
private
-- implementation removed
end AWS.Net.SSL;
</pre></div>
</div>
</div>
<div class="section" id="aws-net-ssl-certificate">
<span id="id29"></span><h2>13.29. AWS.Net.SSL.Certificate<a class="headerlink" href="#aws-net-ssl-certificate" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-31"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Holders</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Net.SSL.Certificate</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="no">Undefined</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Object</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Returns the certificate used by the SSL</span>
<span class="kd">function</span> <span class="nf">Common_Name</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the certificate's common name</span>
<span class="kd">function</span> <span class="nf">Subject</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the certificate's subject</span>
<span class="kd">function</span> <span class="nf">Issuer</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the certificate's issuer</span>
<span class="kd">function</span> <span class="nf">Serial_Number</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the certificate's serial number</span>
<span class="kd">function</span> <span class="nf">DER</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns all certificate's data in DER format</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">"="</span> <span class="p">(</span><span class="nv">Left</span><span class="p">,</span> <span class="nv">Right</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Compare 2 certificates</span>
<span class="kd">function</span> <span class="nf">Load</span> <span class="p">(</span><span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Load certificate from file in PEM format</span>
<span class="kd">function</span> <span class="nf">Activation_Time</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Certificate validity starting date</span>
<span class="kd">function</span> <span class="nf">Expiration_Time</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Certificate validity ending date</span>
<span class="kd">function</span> <span class="nf">Verified</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the certificate has already been verified, this is</span>
<span class="c1">-- mostly interresting when used from the Verify_Callback below. If this</span>
<span class="c1">-- routine returns True it means that the certificate has already been</span>
<span class="c1">-- properly checked. If checked the certificate can be trusted and the</span>
<span class="c1">-- Verify_Callback should return True also. If it is False it is up to</span>
<span class="c1">-- the application to check the certificate into the Verify_Callback and</span>
<span class="c1">-- returns the appropriate status.</span>
<span class="kd">function</span> <span class="nf">Status</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Long_Integer</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the status for the certificate. This is to be used inside the</span>
<span class="c1">-- verify callback to know why the certificate has been rejected.</span>
<span class="kd">function</span> <span class="nf">Status_Message</span> <span class="p">(</span><span class="nv">Certificate</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the error message for the current certificate status (as</span>
<span class="c1">-- returned by Status above).</span>
<span class="c1">--</span>
<span class="c1">-- Client verification support</span>
<span class="c1">--</span>
<span class="kd">type</span> <span class="kt">Verify_Callback</span> <span class="kr">is</span>
<span class="kr">access</span> <span class="kd">function</span> <span class="p">(</span><span class="nv">Cert</span> <span class="p">: </span><span class="nv">SSL</span><span class="p">.</span><span class="nv">Certificate</span><span class="p">.</span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Client certificate verification callback, must return True if Cert can</span>
<span class="c1">-- be accepted or False otherwise. Such callback should generally return</span>
<span class="c1">-- the value returned by Verified above.</span>
<span class="kd">procedure</span> <span class="nf">Set_Verify_Callback</span>
<span class="p">(</span><span class="nv">Config</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">SSL</span><span class="p">.</span><span class="nv">Config</span><span class="p">;</span> <span class="nv">Callback</span> <span class="p">: </span><span class="nv">Verify_Callback</span><span class="p">);</span>
<span class="c1">-- Register the callback to use to verify client's certificates</span>
<span class="kd">type</span> <span class="kt">Password_Callback</span> <span class="kr">is</span>
<span class="kr">access</span> <span class="kd">function</span> <span class="p">(</span><span class="nv">Certificate_Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Callback to get password for signed server's keys. An empty string</span>
<span class="c1">-- must be returned if the password is unknown or the certificate isn't</span>
<span class="c1">-- signed.</span>
<span class="kd">procedure</span> <span class="nf">Set_Password_Callback</span> <span class="p">(</span><span class="nv">Callback</span> <span class="p">: </span><span class="nv">Password_Callback</span><span class="p">);</span>
<span class="c1">-- Set the password callback</span>
<span class="kd">function</span> <span class="nf">Get_Password</span> <span class="p">(</span><span class="nv">Certificate_Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Request a password for the giver certificate. The default</span>
<span class="c1">-- implementation just returns an empty string.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Net.SSL.Certificate</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-websocket">
<span id="id30"></span><h2>13.30. AWS.Net.WebSocket<a class="headerlink" href="#aws-net-websocket" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-32"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2012-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This implements the WebSocket protocol as defined in RFC-6455</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Interfaces</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Net.WebSocket</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Net</span><span class="p">.</span><span class="n">Socket_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Object_Class</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="no">No_Object</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Kind_Type</span>
<span class="kr">is</span> <span class="p">(</span><span class="nv">Unknown</span><span class="p">,</span> <span class="nv">Connection_Open</span><span class="p">,</span> <span class="nv">Text</span><span class="p">,</span> <span class="nv">Binary</span><span class="p">,</span> <span class="nv">Ping</span><span class="p">,</span> <span class="nv">Pong</span><span class="p">,</span> <span class="nv">Connection_Close</span><span class="p">);</span>
<span class="c1">-- Data Frame Kind</span>
<span class="kd">type</span> <span class="kt">Error_Type</span> <span class="kr">is</span>
<span class="p">(</span><span class="nv">Normal_Closure</span><span class="p">,</span>
<span class="nv">Going_Away</span><span class="p">,</span>
<span class="nv">Protocol_Error</span><span class="p">,</span>
<span class="nv">Unsupported_Data</span><span class="p">,</span>
<span class="nv">No_Status_Received</span><span class="p">,</span>
<span class="nv">Abnormal_Closure</span><span class="p">,</span>
<span class="nv">Invalid_Frame_Payload_Data</span><span class="p">,</span>
<span class="nv">Policy_Violation</span><span class="p">,</span>
<span class="nv">Message_Too_Big</span><span class="p">,</span>
<span class="nv">Mandatory_Extension</span><span class="p">,</span>
<span class="nv">Internal_Server_Error</span><span class="p">,</span>
<span class="nv">TLS_Handshake</span><span class="p">,</span>
<span class="nv">Cannot_Resolve_Error</span><span class="p">,</span>
<span class="nv">User_01</span><span class="p">,</span> <span class="c1">-- User's defined error code</span>
<span class="nv">User_02</span><span class="p">,</span>
<span class="nv">User_03</span><span class="p">,</span>
<span class="nv">User_04</span><span class="p">,</span>
<span class="nv">User_05</span><span class="p">);</span>
<span class="c1">--</span>
<span class="c1">-- The following three methods are the one to override or redefine. In fact</span>
<span class="c1">-- the default Send implementation should be ok for most usages.</span>
<span class="c1">--</span>
<span class="kd">function</span> <span class="nf">Create</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Access</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Socket</span> <span class="o">/=</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- Create a new instance of the WebSocket, this is used by AWS internal</span>
<span class="c1">-- server to create a default WebSocket if no other constructor are</span>
<span class="c1">-- provided. It is also needed when deriving from WebSocket.</span>
<span class="kd">procedure</span> <span class="nf">On_Message</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- Default implementation does nothing, it needs to be overriden by the</span>
<span class="c1">-- end-user. This is the callback that will get activated for every server</span>
<span class="c1">-- incoming data. It is also important to keep in mind that the thread</span>
<span class="c1">-- handling this WebSocket won't be released until the procedure returns.</span>
<span class="c1">-- So the code inside this routine should be small and most importantly not</span>
<span class="c1">-- wait for an event to occur otherwise other requests won't be served.</span>
<span class="kd">procedure</span> <span class="nf">On_Message</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">);</span>
<span class="c1">-- Same a above but takes an Unbounded_String. This is supposed to be</span>
<span class="c1">-- overriden when handling large messages otherwise a stack-overflow could</span>
<span class="c1">-- be raised. The default implementation of this procedure to to call the</span>
<span class="c1">-- On_Message above with a string.</span>
<span class="c1">--</span>
<span class="c1">-- So either this version is overriden to handle the incoming messages or</span>
<span class="c1">-- the one above if the messages are known to be small.</span>
<span class="kd">procedure</span> <span class="nf">On_Open</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- As above but activated when a WebSocket is opened</span>
<span class="kd">procedure</span> <span class="nf">On_Close</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- As above but activated when a WebSocket is closed</span>
<span class="kd">procedure</span> <span class="nf">On_Error</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- As above but activated when a WebSocket error is detected</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Is_Binary</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- This default implementation just send a message to the client. The</span>
<span class="c1">-- message is sent in a single chunk (not fragmented).</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Is_Binary</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Same as above but can be used for large messages. The message is</span>
<span class="c1">-- possibly sent fragmented.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Is_Binary</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">);</span>
<span class="c1">-- As above but default is a binary message</span>
<span class="kd">procedure</span> <span class="nf">Close</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Error</span> <span class="p">: </span><span class="nv">Error_Type</span> <span class="p">:=</span> <span class="nv">Normal_Closure</span><span class="p">);</span>
<span class="c1">-- Send a close frame to the WebSocket</span>
<span class="c1">--</span>
<span class="c1">-- Simple accessors to WebSocket state</span>
<span class="c1">--</span>
<span class="kd">function</span> <span class="nf">Kind</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Kind_Type</span><span class="p">;</span>
<span class="c1">-- Returns the message kind of the current read data</span>
<span class="kd">function</span> <span class="nf">Protocol_Version</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the version of the protocol for this WebSocket</span>
<span class="kd">function</span> <span class="nf">URI</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the URI for the WebSocket</span>
<span class="kd">function</span> <span class="nf">Origin</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the Origin of the WebSocket. That is the value of the Origin</span>
<span class="c1">-- header of the client which has opened the socket.</span>
<span class="kd">function</span> <span class="nf">Request</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Status</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Returns Request of the WebSocket. That is the HTTP-request</span>
<span class="c1">-- of the client which has opened the socket.</span>
<span class="kd">function</span> <span class="nf">Error</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Error_Type</span><span class="p">;</span>
<span class="c1">-- Returns the current error type</span>
<span class="kd">function</span> <span class="nf">End_Of_Message</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if we have read a whole message</span>
<span class="c1">--</span>
<span class="c1">-- Socket's methods that must be overriden</span>
<span class="c1">--</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Shutdown</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">How</span> <span class="p">: </span><span class="nv">Shutmode_Type</span> <span class="p">:=</span> <span class="nv">Shut_Read_Write</span><span class="p">);</span>
<span class="c1">-- Shutdown the socket</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_FD</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">FD_Type</span><span class="p">;</span>
<span class="c1">-- Returns the file descriptor associated with the socket</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Peer_Addr</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the peer name/address</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Peer_Port</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="c1">-- Returns the port of the peer socket</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Addr</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the name/address of the socket</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Port</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="c1">-- Returns the port of the socket</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Errno</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span><span class="p">;</span>
<span class="c1">-- Returns and clears error state in socket</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Send_Buffer_Size</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the internal socket send buffer size.</span>
<span class="c1">-- Do not confuse with buffers for the AWS.Net.Buffered operations.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Receive_Buffer_Size</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the internal socket receive buffer size.</span>
<span class="c1">-- Do not confuse with buffers for the AWS.Net.Buffered operations.</span>
<span class="c1">--</span>
<span class="c1">-- Socket reference</span>
<span class="c1">--</span>
<span class="kd">type</span> <span class="kt">UID</span> <span class="kr">is</span> <span class="kr">range</span> <span class="mi">0</span> <span class="p">..</span> <span class="mi">2</span><span class="o">**</span><span class="mi">31</span><span class="p">;</span>
<span class="no">No_UID</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">UID</span><span class="p">;</span>
<span class="c1">-- Not an UID, this is a WebSocket not yet initialized</span>
<span class="kd">function</span> <span class="nf">Get_UID</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">UID</span><span class="p">;</span>
<span class="c1">-- Returns a unique id for the given socket. The uniqueness for this socket</span>
<span class="c1">-- is guaranteed during the lifetime of the application.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Net.WebSocket</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-websocket-registry">
<span id="id31"></span><h2>13.31. AWS.Net.WebSocket.Registry<a class="headerlink" href="#aws-net-websocket-registry" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-33"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2012-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package is used to build and register the active WebSockets. Some</span>
<span class="c1">-- services to send or broadcast messages are also provided.</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">GNAT.Regexp</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Net.WebSocket.Registry</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Factory</span> <span class="kr">is</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span> <span class="kd">function</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Socket_Access</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Creating and Registering WebSockets</span>
<span class="kd">function</span> <span class="nf">Constructor</span> <span class="p">(</span><span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Registry</span><span class="p">.</span><span class="n">Factory</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">URI</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Get the WebObject's constructor for a specific URI</span>
<span class="kd">procedure</span> <span class="nf">Register</span> <span class="p">(</span><span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Factory</span> <span class="p">: </span><span class="nv">Registry</span><span class="p">.</span><span class="nv">Factory</span><span class="p">)</span> <span class="kn">with</span>
<span class="nn">Pre</span> <span class="p">=></span> <span class="n">URI</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Register a WebObject's constructor for a specific URI</span>
<span class="kd">procedure</span> <span class="nf">Register_Pattern</span>
<span class="p">(</span><span class="nv">Pattern</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Factory</span> <span class="p">: </span><span class="nv">Registry</span><span class="p">.</span><span class="nv">Factory</span><span class="p">)</span>
<span class="kn">with</span>
<span class="nn">Pre</span> <span class="p">=></span> <span class="n">Pattern</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Register a WebObject's constructor for a specific URI and pattern</span>
<span class="c1">-- Sending messages</span>
<span class="kd">type</span> <span class="kt">Recipient</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Create</span> <span class="p">(</span><span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Origin</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Recipient</span> <span class="kn">with</span>
<span class="nn">Pre</span> <span class="p">=></span> <span class="n">URI</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- A recipient with only an URI is called a broadcast as it designate all</span>
<span class="c1">-- registered WebSocket for this specific URI. If Origin is specified then</span>
<span class="c1">-- it designates a single client.</span>
<span class="c1">--</span>
<span class="c1">-- Note that both URI and Origin can be regular expressions.</span>
<span class="kd">function</span> <span class="nf">Create</span> <span class="p">(</span><span class="nv">Id</span> <span class="p">: </span><span class="nv">UID</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Recipient</span><span class="p">;</span>
<span class="c1">-- A recipient for a specific WebSocket</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">To</span> <span class="p">: </span><span class="nv">Recipient</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Except_Peer</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- Send a message to the WebSocket designated by Origin and URI. Do not</span>
<span class="c1">-- send this message to the peer whose address is given by Except_Peer.</span>
<span class="c1">-- Except_Peer must be the address as reported by AWS.Net.Peer_Addr. It is</span>
<span class="c1">-- often needed to send a message to all registered sockets except the one</span>
<span class="c1">-- which has sent the message triggering a response.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">To</span> <span class="p">: </span><span class="nv">Recipient</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Except_Peer</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- As above but with an Unbounded_String</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">To</span> <span class="p">: </span><span class="nv">Recipient</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- As above but filter out the client having set the given request</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">To</span> <span class="p">: </span><span class="nv">Recipient</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- As above but with an Unbounded_String</span>
<span class="kd">procedure</span> <span class="nf">Close</span>
<span class="p">(</span><span class="nv">To</span> <span class="p">: </span><span class="nv">Recipient</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Except_Peer</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">;</span>
<span class="nv">Error</span> <span class="p">: </span><span class="nv">Error_Type</span> <span class="p">:=</span> <span class="nv">Normal_Closure</span><span class="p">);</span>
<span class="c1">-- Close connections</span>
<span class="c1">-- Targetting a single WebSocket, these routines are equivalent to the</span>
<span class="c1">-- Net.WebSocket ones but are thread-safe. That is, they can be mixed</span>
<span class="c1">-- with other WebSocket activity to and from the clients.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Is_Binary</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- This default implementation just send a message to the client. The</span>
<span class="c1">-- message is sent in a single chunk (not fragmented).</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Is_Binary</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- Same as above but can be used for large messages. The message is</span>
<span class="c1">-- possibly sent fragmented.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Is_Binary</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="c1">-- As above but for a Stream_Element_Array</span>
<span class="kd">procedure</span> <span class="nf">Close</span>
<span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Forever</span><span class="p">;</span>
<span class="nv">Error</span> <span class="p">: </span><span class="nv">Error_Type</span> <span class="p">:=</span> <span class="nv">Normal_Closure</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Is_Registered</span> <span class="p">(</span><span class="nv">Id</span> <span class="p">: </span><span class="nv">UID</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the WebSocket Id is registered and False otherwise</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Net.WebSocket.Registry</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-net-websocket-registry-control">
<span id="id32"></span><h2>13.32. AWS.Net.WebSocket.Registry.Control<a class="headerlink" href="#aws-net-websocket-registry-control" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-34"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- This package is used to start/stop the WebSockets services</span>
<span class="kd">package</span> <span class="nc">AWS.Net.WebSocket.Registry.Control</span> <span class="kr">is</span>
<span class="kd">procedure</span> <span class="nf">Start</span><span class="p">;</span>
<span class="c1">-- Start the WebSockets servers</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span><span class="p">;</span>
<span class="c1">-- Shutdown the WebSockets servers</span>
<span class="kr">end</span> <span class="nf">AWS.Net.WebSocket.Registry.Control</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-parameters">
<span id="id33"></span><h2>13.33. AWS.Parameters<a class="headerlink" href="#aws-parameters" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-35"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Containers.Tables</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams.Memory</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Parameters</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">List</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">Table_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">VString_Array</span> <span class="kr">is</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">VString_Array</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">URI_Format</span>
<span class="p">(</span><span class="nv">Parameter_List</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Limit</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Positive</span><span class="p">'</span><span class="na">Last</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the list of parameters in the URI format. This can be added</span>
<span class="c1">-- after the resource to form the complete URI. The format is:</span>
<span class="c1">-- "?name1=value1&name2=value2..."</span>
<span class="c1">-- If there is no parameter in the list, the empty string is returned.</span>
<span class="c1">-- Limit is maximum size of the output line, parameters name=value will be</span>
<span class="c1">-- returned unbroken in case of limit applied.</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Parameter_List</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Decode</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- URL decode and add Name=Value pair into parameters</span>
<span class="kd">procedure</span> <span class="nf">Add</span> <span class="p">(</span><span class="nv">Parameter_List</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span> <span class="nv">Parameters</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set parameters for the current request. The Parameters string has the</span>
<span class="c1">-- form "name1=value1&name2=value2...". The paramaters are added to the</span>
<span class="c1">-- list. The parameters can start with a '?' (standard Web character</span>
<span class="c1">-- separator) which is just ignored.</span>
<span class="kd">procedure</span> <span class="nf">Add</span>
<span class="p">(</span><span class="nv">Parameter_List</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span>
<span class="nv">Parameters</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Resources</span><span class="p">.</span><span class="nv">Streams</span><span class="p">.</span><span class="nv">Memory</span><span class="p">.</span><span class="nv">Stream_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Same as above, but use different parameters source. Used to reduce</span>
<span class="c1">-- stack usage on big POST requests. This is the routine used by AWS for</span>
<span class="c1">-- parsing the POST parameters. This routine also control the maximum</span>
<span class="c1">-- number of parameter parsed as set by the corresponding configuration</span>
<span class="c1">-- option.</span>
<span class="kd">procedure</span> <span class="nf">Update</span>
<span class="p">(</span><span class="nv">Parameter_List</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Decode</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="n">Too_Long_Parameter</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised if the Add routine detects a too long parameter line when reading</span>
<span class="c1">-- parameters from Memory_Stream.</span>
<span class="n">Too_Many_Parameters</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when the maximum number of parameters has been reached</span>
<span class="c1">-- See AWS.Containers.Tables for inherited routines</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Parameters</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-pop">
<span id="id34"></span><h2>13.34. AWS.POP<a class="headerlink" href="#aws-pop" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-36"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Headers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net.Std</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.POP</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">POP_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised by all routines when an error has been detected</span>
<span class="c1">-------------</span>
<span class="c1">-- Mailbox --</span>
<span class="c1">-------------</span>
<span class="no">Default_POP_Port</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">110</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Mailbox</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Authenticate_Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Clear_Text</span><span class="p">,</span> <span class="nv">APOP</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Initialize</span>
<span class="p">(</span><span class="nv">Server_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Authenticate</span> <span class="p">: </span><span class="nv">Authenticate_Mode</span> <span class="p">:=</span> <span class="nv">Clear_Text</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Default_POP_Port</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Mailbox</span><span class="p">;</span>
<span class="c1">-- Connect on the given Port to Server_Name and open User's Mailbox. This</span>
<span class="c1">-- mailbox object will be used to retrieve messages.</span>
<span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">);</span>
<span class="c1">-- Close mailbox</span>
<span class="kd">function</span> <span class="nf">User_Name</span> <span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns User's name for this mailbox</span>
<span class="kd">function</span> <span class="nf">Message_Count</span> <span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of messages in the user's mailbox</span>
<span class="kd">function</span> <span class="nf">Size</span> <span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the total size in bytes of the user's mailbox</span>
<span class="c1">-------------</span>
<span class="c1">-- Message --</span>
<span class="c1">-------------</span>
<span class="kd">type</span> <span class="kt">Message</span> <span class="kr">is</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">;</span>
<span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Remove</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Message</span><span class="p">;</span>
<span class="c1">-- Retrieve Nth message from the mailbox, let the message on the mailbox</span>
<span class="c1">-- if Remove is False.</span>
<span class="kd">procedure</span> <span class="nf">Delete</span>
<span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">;</span>
<span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">);</span>
<span class="c1">-- Detele message number N from the mailbox</span>
<span class="kd">function</span> <span class="nf">Get_Header</span>
<span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">;</span>
<span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Message</span><span class="p">;</span>
<span class="c1">-- Retrieve headers for the Nth message from the mailbox, let the message</span>
<span class="c1">-- on the mailbox. This is useful to build a quick summary of the mailbox.</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">Message</span> <span class="p">:</span> <span class="n">POP</span><span class="p">.</span><span class="n">Message</span><span class="p">;</span>
<span class="n">Index</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Message</span>
<span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">;</span>
<span class="nv">Remove</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Calls Action for each message read on the mailbox, delete the message</span>
<span class="c1">-- from the mailbox if Remove is True. Set Quit to True to stop the</span>
<span class="c1">-- iterator. Index is the mailbox's message index.</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">Message</span> <span class="p">:</span> <span class="n">POP</span><span class="p">.</span><span class="n">Message</span><span class="p">;</span>
<span class="n">Index</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Message_Header</span> <span class="p">(</span><span class="nv">Mailbox</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Mailbox</span><span class="p">);</span>
<span class="c1">-- Calls Action for each message read on the mailbox. Only the headers are</span>
<span class="c1">-- read from the mailbox. Set Quit to True to stop the iterator. Index is</span>
<span class="c1">-- the mailbox's message index.</span>
<span class="kd">function</span> <span class="nf">Size</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the message size in bytes</span>
<span class="kd">function</span> <span class="nf">Content</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Returns message's content as an Unbounded_String. Each line are</span>
<span class="c1">-- separated by CR+LF characters.</span>
<span class="kd">function</span> <span class="nf">From</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns From header value</span>
<span class="kd">function</span> <span class="nf">To</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Natural</span> <span class="p">:=</span> <span class="nv">0</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the To header value. If N = 0 returns all recipients separated</span>
<span class="c1">-- by a coma otherwise it returns the Nth To recipient.</span>
<span class="kd">function</span> <span class="nf">To_Count</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of To recipient for Message. returns 0 if there is</span>
<span class="c1">-- no To for this message.</span>
<span class="kd">function</span> <span class="nf">CC</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Natural</span> <span class="p">:=</span> <span class="nv">0</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Retruns the CC header value. If N = 0 returns all recipients separated</span>
<span class="c1">-- by a coma otherwise it returns the Nth CC recipient.</span>
<span class="kd">function</span> <span class="nf">CC_Count</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of CC recipient for Message. Returns 0 if there is</span>
<span class="c1">-- no CC for this message.</span>
<span class="kd">function</span> <span class="nf">Subject</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns Subject header value</span>
<span class="kd">function</span> <span class="nf">Date</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns Date header value</span>
<span class="kd">function</span> <span class="nf">Header</span>
<span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">;</span>
<span class="nv">Header</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns header value for header named Header, returns the empty string</span>
<span class="c1">-- if such header does not exist.</span>
<span class="c1">----------------</span>
<span class="c1">-- Attachment --</span>
<span class="c1">----------------</span>
<span class="kd">type</span> <span class="kt">Attachment</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Attachment_Count</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of Attachments into Message</span>
<span class="kd">function</span> <span class="nf">Get</span>
<span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Index</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Attachment</span><span class="p">;</span>
<span class="c1">-- Returns the Nth Attachment for Message, Raises Constraint_Error if</span>
<span class="c1">-- there is not such attachment.</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">Attachment</span> <span class="p">:</span> <span class="n">POP</span><span class="p">.</span><span class="n">Attachment</span><span class="p">;</span>
<span class="n">Index</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Attachment</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Message</span><span class="p">);</span>
<span class="c1">-- Calls action for every Attachment in Message. Stop iterator if Quit is</span>
<span class="c1">-- set to True, Quit is set to False by default.</span>
<span class="kd">function</span> <span class="nf">Content</span>
<span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Attachment</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Resources</span><span class="p">.</span><span class="n">Streams</span><span class="p">.</span><span class="n">Stream_Access</span><span class="p">;</span>
<span class="c1">-- Returns Attachment's content as a memory stream. Note that the stream</span>
<span class="c1">-- has already been decoded. Most attachments are MIME Base64 encoded.</span>
<span class="kd">function</span> <span class="nf">Content</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Attachment</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Returns Attachment's content as an Unbounded_String. This routine must</span>
<span class="c1">-- only be used for non file attachments. Raises Constraint_Error if</span>
<span class="c1">-- called for a file attachment.</span>
<span class="kd">function</span> <span class="nf">Filename</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Attachment</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the Attachment filename or the empty string if it is not a file</span>
<span class="c1">-- but an embedded message.</span>
<span class="kd">function</span> <span class="nf">Is_File</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Attachment</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if Attachment is a file</span>
<span class="kd">procedure</span> <span class="nf">Write</span> <span class="p">(</span><span class="nv">Attachment</span> <span class="p">: </span><span class="nv">POP</span><span class="p">.</span><span class="nv">Attachment</span><span class="p">;</span> <span class="nv">Directory</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Writes Attachment's file content into Directory. This must only be used</span>
<span class="c1">-- for a file attachment.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.POP</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources">
<span id="id35"></span><h2>13.35. AWS.Resources<a class="headerlink" href="#aws-resources" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-37"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Unchecked_Deallocation</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="n">Resource_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">File_Type</span> <span class="kr">is</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">File_Instance</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">None</span><span class="p">,</span> <span class="nv">Plain</span><span class="p">,</span> <span class="nv">GZip</span><span class="p">,</span> <span class="nv">Both</span><span class="p">);</span>
<span class="c1">-- None : No instance of this file present.</span>
<span class="c1">-- Plain : A non-compressed version of this file exists.</span>
<span class="c1">-- GZip : A gzip encoded version of this file exists.</span>
<span class="c1">-- Both : Both versions of this file exists.</span>
<span class="kd">function</span> <span class="nf">"or"</span> <span class="p">(</span><span class="nv">I1</span><span class="p">,</span> <span class="nv">I2</span> <span class="p">: </span><span class="nv">File_Instance</span><span class="p">)</span> <span class="kr">return</span> <span class="n">File_Instance</span><span class="p">;</span>
<span class="c1">-- Returns the union of I1 and I2</span>
<span class="kd">subtype</span> <span class="kt">Content_Length_Type</span> <span class="kr">is</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="no">Undefined_Length</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Content_Length_Type</span><span class="p">;</span>
<span class="c1">-- Undefined length could be used when we do not know the message stream</span>
<span class="c1">-- length at the start of transfer. The end of message could be determined</span>
<span class="c1">-- by the chunked transfer-encoding in the HTTP/1.1, or by the closing</span>
<span class="c1">-- connection in the HTTP/1.0.</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Form</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Open file in mode In_File. Only reading from the file is supported.</span>
<span class="c1">-- This procedure open the in-memory (embedded) file if present, otherwise</span>
<span class="c1">-- the file on disk is opened. Note that if Name file is not found, it</span>
<span class="c1">-- checks for Name & ".gz" and unzipped the file content in this case.</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Form</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">GZip</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Open file in mode In_File. Only reading from the file is supported.</span>
<span class="c1">-- This procedure open the in-memory (embedded) file if present, otherwise</span>
<span class="c1">-- the file on disk is opened. If GZip parameter is False this call is</span>
<span class="c1">-- equivalent to the Open routine above. If GZip is True this routine will</span>
<span class="c1">-- first check for the compressed version of the resource (Name & ".gz"),</span>
<span class="c1">-- if found GZip output value will remain True. If GZip value is True and</span>
<span class="c1">-- the compressed version of the resource does not exist it looks for</span>
<span class="c1">-- non-compressed version and set GZip value to False.</span>
<span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">File_Type</span><span class="p">);</span>
<span class="c1">-- Reset the file, reading will restart at the beginning</span>
<span class="kd">procedure</span> <span class="nf">Set_Index</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Set the position in the stream, next Read will start at the position</span>
<span class="c1">-- whose index is To. If To is outside the content the index is set to</span>
<span class="c1">-- Last + 1 to ensure that next End_Of_File will return True.</span>
<span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">File_Type</span><span class="p">);</span>
<span class="c1">-- Close the file</span>
<span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Returns a set of bytes from the file</span>
<span class="kd">procedure</span> <span class="nf">Get_Line</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">String</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-- Returns a line from the file. A line is a set of character terminated</span>
<span class="c1">-- by ASCII.LF (UNIX style EOL) or ASCII.CR+ASCII.LF (DOS style EOL).</span>
<span class="kd">function</span> <span class="nf">End_Of_File</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">File_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns true if there is no more data to read</span>
<span class="kd">function</span> <span class="nf">LF_Terminated</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">File_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if last line returned by Get_Line was terminated with a LF</span>
<span class="c1">-- or CR+LF on DOS based systems.</span>
<span class="kd">function</span> <span class="nf">Size</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">File_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Content_Length_Type</span><span class="p">;</span>
<span class="c1">-- Returns the size (in bytes) of the resource. If the size of the</span>
<span class="c1">-- resource is not defined, the routine Size returns Undefined_Length</span>
<span class="c1">-- value.</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">File_Instance</span><span class="p">;</span>
<span class="c1">-- Return GZip if only file Name & ".gz" exists.</span>
<span class="c1">-- Return Plain if only file Name exists.</span>
<span class="c1">-- Return Both if both file Name and Name & ".gz" exists.</span>
<span class="c1">-- Return None if files neither Name nor Name & ".gz" exist.</span>
<span class="kd">function</span> <span class="nf">Is_Regular_File</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if Filename is a regular file and is readable. Checks</span>
<span class="c1">-- first for in memory file then for disk file.</span>
<span class="kd">function</span> <span class="nf">File_Size</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Utils</span><span class="p">.</span><span class="n">File_Size_Type</span><span class="p">;</span>
<span class="c1">-- Returns Filename's size in bytes. Checks first for in memory file</span>
<span class="c1">-- then for disk file.</span>
<span class="kd">function</span> <span class="nf">File_Timestamp</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="c1">-- Get the time for last modification to a file in UTC/GMT. Checks first</span>
<span class="c1">-- for in memory file then for disk file.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Resources</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-embedded">
<span id="id36"></span><h2>13.36. AWS.Resources.Embedded<a class="headerlink" href="#aws-resources-embedded" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-38"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams.Memory</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Embedded</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="n">Resource_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">Resources</span><span class="p">.</span><span class="n">Resource_Error</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Buffer_Access</span> <span class="kr">is</span> <span class="n">Streams</span><span class="p">.</span><span class="n">Memory</span><span class="p">.</span><span class="n">Buffer_Access</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Form</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">GZip</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Open resource from registered data</span>
<span class="kd">procedure</span> <span class="nf">Create</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">Buffer_Access</span><span class="p">);</span>
<span class="c1">-- Create the resource directly from memory data</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">File_Instance</span><span class="p">;</span>
<span class="c1">-- Return GZip if only file Name & ".gz" exists.</span>
<span class="c1">-- Return Plain if only file Name exists.</span>
<span class="c1">-- Return Both if both file Name and Name & ".gz" exists.</span>
<span class="c1">-- Return None if files neither Name nor Name & ".gz" exist.</span>
<span class="kd">function</span> <span class="nf">Is_Regular_File</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if file named Name has been registered (i.e. it is an</span>
<span class="c1">-- in-memory file).</span>
<span class="kd">function</span> <span class="nf">File_Size</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Utils</span><span class="p">.</span><span class="n">File_Size_Type</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">File_Timestamp</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Content</span> <span class="p">: </span><span class="nv">Buffer_Access</span><span class="p">;</span>
<span class="nv">File_Time</span> <span class="p">: </span><span class="nv">Calendar</span><span class="p">.</span><span class="nv">Time</span><span class="p">);</span>
<span class="c1">-- Register a new file named Name into the embedded resources. The file</span>
<span class="c1">-- content is pointed to by Content, the File_Time must be the last</span>
<span class="c1">-- modification time stamp for the file. If Name ends with ".gz" the</span>
<span class="c1">-- embedded resource registered as compressed. If a file is already</span>
<span class="c1">-- registered for this name, Content replace the previous one.</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Embedded</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-files">
<span id="id37"></span><h2>13.37. AWS.Resources.Files<a class="headerlink" href="#aws-resources-files" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-39"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Files</span> <span class="kr">is</span>
<span class="n">Resource_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">Resources</span><span class="p">.</span><span class="n">Resource_Error</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Form</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">GZip</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Form</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">File_Instance</span><span class="p">;</span>
<span class="c1">-- Return GZip if only file Name & ".gz" exists.</span>
<span class="c1">-- Return Plain if only file Name exists.</span>
<span class="c1">-- Return Both if both file Name and Name & ".gz" exists.</span>
<span class="c1">-- Return None if files neither Name nor Name & ".gz" exist.</span>
<span class="kd">function</span> <span class="nf">Is_Regular_File</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">File_Size</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Utils</span><span class="p">.</span><span class="n">File_Size_Type</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">File_Timestamp</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Files</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-streams">
<span id="id38"></span><h2>13.38. AWS.Resources.Streams<a class="headerlink" href="#aws-resources-streams" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-40"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2002-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Streams</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Stream_Type</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">tagged</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Stream_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">Stream_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">End_Of_File</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Set_Index</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Set the position in the stream, next Read will start at the position</span>
<span class="c1">-- whose index is To. If To is outside the content the index is set to</span>
<span class="c1">-- Last + 1 to ensure that next End_Of_File will return True.</span>
<span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Size</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="c1">-- This default implementation returns Undefined_Length. If the derived</span>
<span class="c1">-- stream implementation knows about the size (in bytes) of the stream</span>
<span class="c1">-- this routine should be redefined.</span>
<span class="kd">function</span> <span class="nf">Name</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- This default implementation returns the empty string. It is must be</span>
<span class="c1">-- overwritten by file based stream to provide the proper filename</span>
<span class="c1">-- associated with the stream.</span>
<span class="kd">procedure</span> <span class="nf">Create</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">Stream</span> <span class="p">: </span><span class="nv">Stream_Access</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Create a resource file from user defined stream</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Streams</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-streams-disk">
<span id="id39"></span><h2>13.39. AWS.Resources.Streams.Disk<a class="headerlink" href="#aws-resources-streams-disk" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-41"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- An ready-to-use implementation of the stream API where the stream content</span>
<span class="c1">-- is read from an on-disk file.</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Streams.Stream_IO</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Streams.Disk</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Stream_Type</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Streams</span><span class="p">.</span><span class="n">Stream_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Form</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"shared=no"</span><span class="p">);</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">End_Of_File</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Size</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Name</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Set_Index</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Streams.Disk</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-streams-disk-once">
<span id="id40"></span><h2>13.40. AWS.Resources.Streams.Disk.Once<a class="headerlink" href="#aws-resources-streams-disk-once" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-42"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- An ready-to-use implementation of the stream API where the stream content</span>
<span class="c1">-- is read from an on-disk file. The file is removed from the file system</span>
<span class="c1">-- when the transfer is completed.</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Streams.Disk.Once</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Stream_Type</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Disk</span><span class="p">.</span><span class="n">Stream_Type</span> <span class="kr">with</span> <span class="kr">null record</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="c1">-- Only redefine Close that will not only close the stream but also delete</span>
<span class="c1">-- the file.</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Streams.Disk.Once</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-streams-memory">
<span id="id41"></span><h2>13.41. AWS.Resources.Streams.Memory<a class="headerlink" href="#aws-resources-streams-memory" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-43"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- API to handle a memory stream. A memory stream is first created</span>
<span class="c1">-- empty. User can add chunk of data using the Append routines. The stream</span>
<span class="c1">-- is then read using the Read procedure.</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Containers.Memory_Streams</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Streams.Memory</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Stream_Type</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Streams</span><span class="p">.</span><span class="n">Stream_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Stream_Element_Access</span> <span class="kr">is</span> <span class="n">Utils</span><span class="p">.</span><span class="n">Stream_Element_Array_Access</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Buffer_Access</span> <span class="kr">is</span> <span class="n">Utils</span><span class="p">.</span><span class="n">Stream_Element_Array_Constant_Access</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Append</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Trim</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Append Buffer into the memory stream</span>
<span class="kd">procedure</span> <span class="nf">Append</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">Stream_Element_Access</span><span class="p">);</span>
<span class="c1">-- Append static data pointed to Buffer into the memory stream as is.</span>
<span class="c1">-- The stream will free the memory on close.</span>
<span class="kd">procedure</span> <span class="nf">Append</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">Buffer_Access</span><span class="p">);</span>
<span class="c1">-- Append static data pointed to Buffer into the memory stream as is.</span>
<span class="c1">-- The stream would not try to free the memory on close.</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Returns a chunck of data in Buffer, Last point to the last element</span>
<span class="c1">-- returned in Buffer.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">End_Of_File</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the end of the memory stream has been reached</span>
<span class="kd">procedure</span> <span class="nf">Clear</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Delete all data from memory stream</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="c1">-- Reset the streaming data to the first position</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Set_Index</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Set the position in the stream, next Read will start at the position</span>
<span class="c1">-- whose index is To.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Size</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="c1">-- Returns the number of bytes in the memory stream</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="c1">-- Close the memory stream. Release all memory associated with the stream</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Streams.Memory</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-streams-memory-zlib">
<span id="id42"></span><h2>13.42. AWS.Resources.Streams.Memory.ZLib<a class="headerlink" href="#aws-resources-streams-memory-zlib" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-44"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This API is used as for standard memory stream (see parent package), the</span>
<span class="c1">-- only difference is that the stream is compressing/decompressing on append.</span>
<span class="kn">with</span> <span class="nn">ZLib</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Streams.Memory.ZLib</span> <span class="kr">is</span>
<span class="kd">package</span> <span class="nc">ZL</span> <span class="kr">renames</span> <span class="nc">Standard.ZLib</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Stream_Type</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Memory</span><span class="p">.</span><span class="n">Stream_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Window_Bits_Type</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Window_Bits_Type</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Header_Type</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Header_Type</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Compression_Level</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Compression_Level</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Strategy_Type</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Strategy_Type</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Compression_Method</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Compression_Method</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Memory_Level_Type</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Memory_Level_Type</span><span class="p">;</span>
<span class="no">Default_Compression</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Compression_Level</span> <span class="p">:=</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Default_Compression</span><span class="p">;</span>
<span class="no">Default_Header</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Header_Type</span> <span class="p">:=</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Default</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Deflate_Initialize</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Level</span> <span class="p">: </span><span class="nv">Compression_Level</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Compression</span><span class="p">;</span>
<span class="nv">Strategy</span> <span class="p">: </span><span class="nv">Strategy_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Strategy</span><span class="p">;</span>
<span class="nv">Method</span> <span class="p">: </span><span class="nv">Compression_Method</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Deflated</span><span class="p">;</span>
<span class="nv">Window_Bits</span> <span class="p">: </span><span class="nv">Window_Bits_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Window_Bits</span><span class="p">;</span>
<span class="nv">Memory_Level</span> <span class="p">: </span><span class="nv">Memory_Level_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Memory_Level</span><span class="p">;</span>
<span class="nv">Header</span> <span class="p">: </span><span class="nv">Header_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Initialize the compression</span>
<span class="kd">procedure</span> <span class="nf">Inflate_Initialize</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Window_Bits</span> <span class="p">: </span><span class="nv">Window_Bits_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Window_Bits</span><span class="p">;</span>
<span class="nv">Header</span> <span class="p">: </span><span class="nv">Header_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Initialize the decompression</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Append</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Trim</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Compress/decompress and Append Buffer into the memory stream</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="c1">-- Returns a chunck of data in Buffer, Last point to the last element</span>
<span class="c1">-- returned in Buffer.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Size</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span><span class="p">;</span>
<span class="c1">-- Returns the number of bytes in the memory stream</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="c1">-- Close the ZLib stream, release all memory associated with the Resource</span>
<span class="c1">-- object.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Streams.Memory.ZLib</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-resources-streams-pipe">
<span id="id43"></span><h2>13.43. AWS.Resources.Streams.Pipe<a class="headerlink" href="#aws-resources-streams-pipe" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-45"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2007-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- An ready-to-use implementation of the stream API where the stream content</span>
<span class="c1">-- is read from a pipe.</span>
<span class="kn">with</span> <span class="nn">GNAT.OS_Lib</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">GNAT.Expect</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Resources.Streams.Pipe</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">GNAT</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Stream_Type</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Streams</span><span class="p">.</span><span class="n">Stream_Type</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">On_Error_Callback</span> <span class="kr">is</span>
<span class="kr">access</span> <span class="kd">procedure</span> <span class="p">(</span><span class="nv">Status</span> <span class="p">: </span><span class="nv">Integer</span><span class="p">;</span> <span class="nv">Error</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Open</span>
<span class="p">(</span><span class="nv">Pipe</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Command</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Args</span> <span class="p">: </span><span class="nv">OS_Lib</span><span class="p">.</span><span class="nv">Argument_List</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Integer</span> <span class="p">:=</span> <span class="nv">10_000</span><span class="p">;</span>
<span class="nv">On_Error</span> <span class="p">: </span><span class="nv">On_Error_Callback</span> <span class="p">:=</span> <span class="nv">null</span><span class="p">);</span>
<span class="c1">-- Open the pipe and connect it to the given command's output. Args are</span>
<span class="c1">-- passed to the command. Timeout is given in milliseconds and corresponds</span>
<span class="c1">-- to the time waiting for output data before timeout. This timeout must be</span>
<span class="c1">-- adjusted to be compatible to the output activity of the Command process.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">End_Of_File</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Read</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">);</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Close</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">);</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Reset</span> <span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- Does nothing as not supported on pipe streams</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Set_Index</span>
<span class="p">(</span><span class="nv">Resource</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Stream_Type</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Stream_Element_Offset</span><span class="p">)</span> <span class="kr">is</span> <span class="kc">null</span><span class="p">;</span>
<span class="c1">-- Does nothing as not supported on pipe streams</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Resources.Streams.Pipe</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-response">
<span id="id44"></span><h2>13.44. AWS.Response<a class="headerlink" href="#aws-response" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-46"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package is to be used to build answer to be sent to the client</span>
<span class="c1">-- browser. It is also used as the object returned from the client API. So</span>
<span class="c1">-- it is either a response built on the server side or the response received</span>
<span class="c1">-- on the client side.</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Headers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Messages</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.MIME</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Unchecked_Deallocation</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Response</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">type</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Messages</span><span class="p">.</span><span class="n">Status_Code</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Data</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Note that this type use a reference counter which is not thread safe</span>
<span class="kd">type</span> <span class="kt">Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">function</span> <span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Data</span><span class="p">;</span>
<span class="c1">-- This is the Web Server Callback procedure. A client must declare and</span>
<span class="c1">-- pass such procedure to the HTTP server.</span>
<span class="kd">type</span> <span class="kt">Data_Mode</span> <span class="kr">is</span>
<span class="p">(</span><span class="nv">Header</span><span class="p">,</span> <span class="c1">-- Send only the HTTP header</span>
<span class="nv">Message</span><span class="p">,</span> <span class="c1">-- Send a standard HTTP message</span>
<span class="nv">File</span><span class="p">,</span> <span class="c1">-- Send a file</span>
<span class="nv">File_Once</span><span class="p">,</span> <span class="c1">-- Send a file once, delete it after sending</span>
<span class="nv">Stream</span><span class="p">,</span> <span class="c1">-- Send a stream</span>
<span class="nv">Socket_Taken</span><span class="p">,</span> <span class="c1">-- Socket has been taken from the server</span>
<span class="nv">WebSocket</span><span class="p">,</span> <span class="c1">-- Protocol switched to WebSocket</span>
<span class="nv">No_Data</span><span class="p">);</span> <span class="c1">-- No data, this is not a response</span>
<span class="kd">type</span> <span class="kt">Authentication_Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Unknown</span><span class="p">,</span> <span class="nv">Any</span><span class="p">,</span> <span class="nv">Basic</span><span class="p">,</span> <span class="nv">Digest</span><span class="p">);</span>
<span class="c1">-- The authentication mode.</span>
<span class="c1">-- "Basic" and "Digest" mean that server must accept the requested</span>
<span class="c1">-- authentication mode. "Any" mean that server could accept any</span>
<span class="c1">-- authentication from client.</span>
<span class="c1">-- Unknown, means that an unsupported mode has been found.</span>
<span class="c1">-- Note the order here should not be changed as it is used in AWS.Client.</span>
<span class="kd">subtype</span> <span class="kt">Content_Length_Type</span>
<span class="kr">is</span> <span class="n">Stream_Element_Offset</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">1</span> <span class="p">..</span> <span class="n">Stream_Element_Offset</span><span class="p">'</span><span class="na">Last</span><span class="p">;</span>
<span class="no">Undefined_Length</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Content_Length_Type</span><span class="p">;</span>
<span class="c1">-- Undefined length could be used when we do not know the message length</span>
<span class="c1">-- at the start of transfer. The end of message could be determined by the</span>
<span class="c1">-- chunked transfer-encoding in the HTTP/1.1, or by the closing connection</span>
<span class="c1">-- in the HTTP/1.0.</span>
<span class="no">Default_Moved_Message</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- This is a template message, _@_ will be replaced by the Location (see</span>
<span class="c1">-- function Build with Location below).</span>
<span class="no">Default_Authenticate_Message</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- This is the message that will be displayed on the Web Browser if the</span>
<span class="c1">-- authentication process fails or is cancelled.</span>
<span class="c1">-----------------------</span>
<span class="c1">-- Data Constructors --</span>
<span class="c1">-----------------------</span>
<span class="kd">function</span> <span class="nf">Build</span>
<span class="p">(</span><span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message_Body</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">S200</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Content_Encoding</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Identity</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Build</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Response</span><span class="p">.</span><span class="n">Status_Code</span> <span class="p">(</span><span class="n">Build</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Status_Code</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Build</span>
<span class="p">(</span><span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">UString_Message</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">S200</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Content_Encoding</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Identity</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Build</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Response</span><span class="p">.</span><span class="n">Status_Code</span> <span class="p">(</span><span class="n">Build</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Status_Code</span><span class="p">;</span>
<span class="c1">-- Return a message whose body is passed into Message_Body. The</span>
<span class="c1">-- Content_Type parameter is the MIME type for the message</span>
<span class="c1">-- body. Status_Code is the response status (see Messages.Status_Code</span>
<span class="c1">-- definition).</span>
<span class="kd">function</span> <span class="nf">Build</span>
<span class="p">(</span><span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message_Body</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">S200</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Content_Encoding</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Identity</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Build</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Response</span><span class="p">.</span><span class="n">Status_Code</span> <span class="p">(</span><span class="n">Build</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Status_Code</span><span class="p">;</span>
<span class="c1">-- Idem above, but the message body is a stream element array</span>
<span class="kd">type</span> <span class="kt">Disposition_Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Attachment</span><span class="p">,</span> <span class="nv">Inline</span><span class="p">,</span> <span class="nv">None</span><span class="p">);</span>
<span class="c1">-- Describes the way a file/stream is sent to the browser.</span>
<span class="c1">--</span>
<span class="c1">-- Attachment : The file is sent as an attachment, the browser</span>
<span class="c1">-- wont display the content even if the MIME type</span>
<span class="c1">-- is supported (.txt or .doc on IE for example).</span>
<span class="c1">--</span>
<span class="c1">-- Inline : The file can be displayed inside the browser if</span>
<span class="c1">-- MIME type is supported. If not the browser will</span>
<span class="c1">-- propose to save this file.</span>
<span class="c1">--</span>
<span class="c1">-- None : No specific setting is sent to the browser. The</span>
<span class="c1">-- browser default setting will be used. Note that in</span>
<span class="c1">-- this case the browser determine the filename using</span>
<span class="c1">-- the URI. This is the default setting.</span>
<span class="kd">function</span> <span class="nf">File</span>
<span class="p">(</span><span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">S200</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Content_Encoding</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Identity</span><span class="p">;</span>
<span class="nv">Once</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Disposition</span> <span class="p">: </span><span class="nv">Disposition_Mode</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">;</span>
<span class="nv">User_Filename</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">File</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Response</span><span class="p">.</span><span class="n">Status_Code</span> <span class="p">(</span><span class="n">File</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Status_Code</span>
<span class="ow">and then</span> <span class="p">(</span><span class="kr">if</span> <span class="n">Once</span>
<span class="kr">then</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">File</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">File_Once</span>
<span class="kr">else</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">File</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">File</span><span class="p">);</span>
<span class="c1">-- Returns a message whose message body is the content of the file. The</span>
<span class="c1">-- Content_Type must indicate the MIME type for the file. User_Filename</span>
<span class="c1">-- can be used to force the filename on the client side. This can be</span>
<span class="c1">-- different from the server side Filename. If Once is set to True the</span>
<span class="c1">-- file will be deleted after the download (this includes the case where</span>
<span class="c1">-- the download is suspended).</span>
<span class="kd">function</span> <span class="nf">Stream</span>
<span class="p">(</span><span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Handle</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">Resources</span><span class="p">.</span><span class="nv">Streams</span><span class="p">.</span><span class="nv">Stream_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">S200</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">No_Cache</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Content_Encoding</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Identity</span><span class="p">;</span>
<span class="nv">Server_Close</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Disposition</span> <span class="p">: </span><span class="nv">Disposition_Mode</span> <span class="p">:=</span> <span class="nv">None</span><span class="p">;</span>
<span class="nv">User_Filename</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Stream</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Response</span><span class="p">.</span><span class="n">Status_Code</span> <span class="p">(</span><span class="n">Stream</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Status_Code</span><span class="p">;</span>
<span class="c1">-- Returns a message whose message body is the content of the user defined</span>
<span class="c1">-- stream. The Content_Type must indicate the MIME type for the data</span>
<span class="c1">-- stream, Status_Code is the the header status code which should be send</span>
<span class="c1">-- back to client's browser. If Server_Close is set to False the server</span>
<span class="c1">-- will not close the stream after sending it, it is then user's</span>
<span class="c1">-- responsability to close the stream. User_Filename can be used to force</span>
<span class="c1">-- the filename on the client side. This can be different from the server</span>
<span class="c1">-- side filename (for file based stream) or can be used to name a non disk</span>
<span class="c1">-- based stream. Encoding mean additional encoding would be applied on top</span>
<span class="c1">-- of given Handler stream.</span>
<span class="c1">------------------------------</span>
<span class="c1">-- Redirection Constructors --</span>
<span class="c1">------------------------------</span>
<span class="kd">function</span> <span class="nf">URL</span>
<span class="p">(</span><span class="nv">Location</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">URL</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Status_Code</span> <span class="p">(</span><span class="n">URL</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Messages</span><span class="p">.</span><span class="n">S302</span>
<span class="ow">and then</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">URL</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Header</span><span class="p">;</span>
<span class="c1">-- This ask the server for a redirection to the specified URL. This is</span>
<span class="c1">-- a temporary redirection, and the client browser should query the</span>
<span class="c1">-- same original URL next time.</span>
<span class="kd">function</span> <span class="nf">Moved</span>
<span class="p">(</span><span class="nv">Location</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default_Moved_Message</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Moved</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Status_Code</span> <span class="p">(</span><span class="n">Moved</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Messages</span><span class="p">.</span><span class="n">S301</span><span class="p">;</span>
<span class="c1">-- This send back a moved message (Messages.S301) with the specified</span>
<span class="c1">-- message body.</span>
<span class="c1">-- This is a permanent redirection, and the client browser is encouraged</span>
<span class="c1">-- to update links so that the next query for the URL goes directly to</span>
<span class="c1">-- the new location.</span>
<span class="c1">------------------------</span>
<span class="c1">-- Other Constructors --</span>
<span class="c1">------------------------</span>
<span class="kd">function</span> <span class="nf">Acknowledge</span>
<span class="p">(</span><span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span><span class="p">;</span>
<span class="nv">Message_Body</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_HTML</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span>
<span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Acknowledge</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Response</span><span class="p">.</span><span class="n">Status_Code</span> <span class="p">(</span><span class="n">Acknowledge</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Status_Code</span>
<span class="ow">and then</span> <span class="p">(</span><span class="kr">if</span> <span class="n">Message_Body</span> <span class="o">=</span> <span class="s">""</span>
<span class="kr">then</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">Acknowledge</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Header</span><span class="p">);</span>
<span class="c1">-- Returns a message to the Web browser. This routine must be used to</span>
<span class="c1">-- send back an error message to the Web browser. For example if a</span>
<span class="c1">-- requested resource cannot be served a message with status code S404</span>
<span class="c1">-- must be sent.</span>
<span class="kd">function</span> <span class="nf">Authenticate</span>
<span class="p">(</span><span class="nv">Realm</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Authentication_Mode</span> <span class="p">:=</span> <span class="nv">Basic</span><span class="p">;</span>
<span class="nv">Stale</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default_Authenticate_Message</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Is_Empty</span> <span class="p">(</span><span class="n">Authenticate</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Status_Code</span> <span class="p">(</span><span class="n">Authenticate</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Messages</span><span class="p">.</span><span class="n">S401</span><span class="p">;</span>
<span class="c1">-- Returns an authentication message (Messages.S401), the Web browser</span>
<span class="c1">-- will then ask for an authentication. Realm string will be displayed</span>
<span class="c1">-- by the Web Browser in the authentication dialog box.</span>
<span class="kd">function</span> <span class="nf">Socket_Taken</span> <span class="nf">return</span> <span class="nf">Data</span> <span class="nf">with</span>
<span class="nf">Post</span> <span class="p">=></span> <span class="nf">not</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">Socket_Taken</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">Socket_Taken</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Socket_Taken</span><span class="p">;</span>
<span class="c1">-- Must be used to say that the connection socket has been taken by user</span>
<span class="c1">-- inside of user callback. No operations should be performed on this</span>
<span class="c1">-- socket, and associated slot should be released for further operations.</span>
<span class="kd">function</span> <span class="nf">Empty</span> <span class="nf">return</span> <span class="nf">Data</span> <span class="nf">with</span>
<span class="nf">Post</span> <span class="p">=></span> <span class="nf">Status_Code</span> <span class="p">(</span><span class="nv">Empty</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Messages</span><span class="p">.</span><span class="n">S204</span>
<span class="ow">and then</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">Empty</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">No_Data</span><span class="p">;</span>
<span class="c1">-- Returns an empty message (Data_Mode = No_Data and Status_Code is 204).</span>
<span class="c1">-- It is used to say that user's handlers were not able to do something</span>
<span class="c1">-- with the request. This is used by the callback's chain in the</span>
<span class="c1">-- dispatchers and should not be used by users.</span>
<span class="c1">--</span>
<span class="c1">-- API to retrieve response data</span>
<span class="c1">--</span>
<span class="c1">------------</span>
<span class="c1">-- Header --</span>
<span class="c1">------------</span>
<span class="kd">function</span> <span class="nf">Header</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Return the N-th value for header Name</span>
<span class="kd">function</span> <span class="nf">Header</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Return all values as a comma-separated string for header Name.</span>
<span class="c1">-- See [RFC 2616 - 4.2] last paragraph.</span>
<span class="kd">function</span> <span class="nf">Header</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Headers</span><span class="p">.</span><span class="n">List</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Has_Header</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if D headers contains Name</span>
<span class="kd">procedure</span> <span class="nf">Send_Header</span> <span class="p">(</span><span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Send all header lines to the socket</span>
<span class="kd">function</span> <span class="nf">Status_Code</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Status_Code</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the status code</span>
<span class="kd">function</span> <span class="nf">Content_Length</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Content_Length_Type</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the content length (i.e. the message body length). A value of 0</span>
<span class="c1">-- indicate that there is no message body.</span>
<span class="kd">function</span> <span class="nf">Content_Type</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the MIME type for the message body</span>
<span class="kd">function</span> <span class="nf">Cache_Control</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Cache_Option</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the cache control specified for the response</span>
<span class="kd">function</span> <span class="nf">Cache_Control</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Cache_Data</span><span class="p">;</span>
<span class="c1">-- As above but returns a structured record of type "Cache_Data (Request)"</span>
<span class="c1">-- representing the cache options.</span>
<span class="kd">function</span> <span class="nf">Expires</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the Expires date as a time value</span>
<span class="kd">function</span> <span class="nf">Location</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the location for the new page in the case of a moved</span>
<span class="c1">-- message. See Moved constructor above.</span>
<span class="c1">----------</span>
<span class="c1">-- Data --</span>
<span class="c1">----------</span>
<span class="kd">function</span> <span class="nf">Mode</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Data_Mode</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the data mode, either Header, Message or File</span>
<span class="kd">function</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if D.Mode is No_Data</span>
<span class="kd">function</span> <span class="nf">Message_Body</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the message body content as a string.</span>
<span class="c1">-- Message_Body routines could not be used with user defined streams</span>
<span class="c1">-- (see. Stream routine in this package). Constraint_Error would be raised</span>
<span class="c1">-- on try to get data by the Message_Body from the user defined streams.</span>
<span class="c1">-- For get data from user defined streams routine Create_Resource should</span>
<span class="c1">-- be used.</span>
<span class="kd">function</span> <span class="nf">Message_Body</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Returns message body content as an unbounded_string</span>
<span class="kd">function</span> <span class="nf">Message_Body</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span><span class="p">;</span>
<span class="c1">-- Returns message body as a binary content</span>
<span class="kd">procedure</span> <span class="nf">Message_Body</span>
<span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Resources</span><span class="p">.</span><span class="nv">File_Type</span><span class="p">);</span>
<span class="c1">-- Returns the message body as a stream</span>
<span class="kd">function</span> <span class="nf">Filename</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the filename which should be sent back or the filename which</span>
<span class="c1">-- was containing the response for a server response.</span>
<span class="c1">--------------------</span>
<span class="c1">-- Authentication --</span>
<span class="c1">--------------------</span>
<span class="kd">function</span> <span class="nf">Realm</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the Realm for the current authentication request</span>
<span class="kd">function</span> <span class="nf">Authentication</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Authentication_Mode</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the authentication mode requested by server</span>
<span class="kd">function</span> <span class="nf">Authentication_Stale</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the stale parameter for authentication</span>
<span class="c1">---------------</span>
<span class="c1">-- Resources --</span>
<span class="c1">---------------</span>
<span class="kd">procedure</span> <span class="nf">Create_Resource</span>
<span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Data</span><span class="p">;</span>
<span class="nv">File</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Resources</span><span class="p">.</span><span class="nv">File_Type</span><span class="p">;</span>
<span class="nv">GZip</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Creates the resource object (either a file or in-memory object) for</span>
<span class="c1">-- the data to be sent to the client. The resource should be closed after</span>
<span class="c1">-- use.</span>
<span class="c1">-- GZip is true when the http client support GZip decoding,</span>
<span class="c1">-- if file or embedded resource is in the GZip format this routine would</span>
<span class="c1">-- define Content-Encoding header field value.</span>
<span class="kd">function</span> <span class="nf">Close_Resource</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the resource stream must be close</span>
<span class="kd">function</span> <span class="nf">Keep_Alive</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the user want to keep connection alive</span>
<span class="c1">----------------</span>
<span class="c1">-- WebSockets --</span>
<span class="c1">----------------</span>
<span class="kd">function</span> <span class="nf">WebSocket</span> <span class="nf">return</span> <span class="nf">Data</span> <span class="nf">with</span>
<span class="nf">Post</span> <span class="p">=></span> <span class="nf">not</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">WebSocket</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span>
<span class="ow">and then</span> <span class="n">Status_Code</span> <span class="p">(</span><span class="n">WebSocket</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Messages</span><span class="p">.</span><span class="n">S101</span>
<span class="ow">and then</span> <span class="n">Mode</span> <span class="p">(</span><span class="n">WebSocket</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">WebSocket</span><span class="p">;</span>
<span class="c1">-- WebSocket handshake from initial WebSocket connection</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Response</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-server">
<span id="id45"></span><h2>13.45. AWS.Server<a class="headerlink" href="#aws-server" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-47"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Config</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Default</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Exceptions</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net.SSL</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Exceptions</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Task_Attributes</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Task_Identification</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Real_Time</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">System</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Log</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Net.Acceptors</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Hotplug</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Server</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">HTTP</span> <span class="kr">is</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- A Web server</span>
<span class="c1">---------------------------</span>
<span class="c1">-- Server initialization --</span>
<span class="c1">---------------------------</span>
<span class="c1">-- Note that starting a sercure server if AWS has not been configured to</span>
<span class="c1">-- support HTTPS will raise Program_Error.</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Callback</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">Config</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Config</span><span class="p">.</span><span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Start server using a full configuration object. With this routine it is</span>
<span class="c1">-- possible to control all features of the server. A simplified version of</span>
<span class="c1">-- Start is also provided below with the most common options.</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Config</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Config</span><span class="p">.</span><span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Idem, but using the dispatcher tagged type instead of callback. See</span>
<span class="c1">-- AWS.Services.Dispatchers and AWS.Dispatchers hierarchies for built-in</span>
<span class="c1">-- services and interface to build your own dispatcher models.</span>
<span class="c1">-- Note that a copy of the Dispatcher is keept into Web_Server. Any</span>
<span class="c1">-- changes done to the Dispatcher object will not be part of the Web</span>
<span class="c1">-- server dispatcher.</span>
<span class="kd">procedure</span> <span class="nf">Get_Message_Body</span><span class="p">;</span>
<span class="c1">-- If size of message body is bigger than Upload_Size_Limit configuration</span>
<span class="c1">-- parameter, server do not receive message body before calling user's</span>
<span class="c1">-- callback routine. If user decide to get the message body he should call</span>
<span class="c1">-- this routine.</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Callback</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">Max_Connection</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Max_Connection</span><span class="p">;</span>
<span class="nv">Admin_URI</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Admin_URI</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Natural</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Server_Port</span><span class="p">;</span>
<span class="nv">Security</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Session</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Case_Sensitive_Parameters</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Upload_Directory</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Upload_Directory</span><span class="p">;</span>
<span class="nv">Line_Stack_Size</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Line_Stack_Size</span><span class="p">);</span>
<span class="c1">-- Start the Web server. Max_Connection is the number of simultaneous</span>
<span class="c1">-- connections the server's will handle (the number of slots in AWS).</span>
<span class="c1">-- Name is just a string used to identify the server. This is used</span>
<span class="c1">-- for example in the administrative page. Admin_URI must be set to enable</span>
<span class="c1">-- the administrative status page. Callback is the procedure to call for</span>
<span class="c1">-- each resource requested. Port is the Web server port. If Security is</span>
<span class="c1">-- set to True the server will use an HTTPS/SSL connection. If Session is</span>
<span class="c1">-- set to True the server will be able to get a status for each client</span>
<span class="c1">-- connected. A session Id is used for that, on the client side it is a</span>
<span class="c1">-- cookie. Case_Sensitive_Parameters if set to False it means that the</span>
<span class="c1">-- parameters name will be handled without case sensitivity. Upload</span>
<span class="c1">-- directory point to a directory where uploaded files will be stored.</span>
<span class="c1">------------------------</span>
<span class="c1">-- Server termination --</span>
<span class="c1">------------------------</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">);</span>
<span class="c1">-- Stop the server and release all associated memory. This routine can</span>
<span class="c1">-- take some time to terminate because it waits for all tasks to terminate</span>
<span class="c1">-- properly before releasing the memory. The log facilities will be</span>
<span class="c1">-- automatically stopped by calling Stop_Log below.</span>
<span class="kd">type</span> <span class="kt">Termination</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">No_Server</span><span class="p">,</span> <span class="nv">Q_Key_Pressed</span><span class="p">,</span> <span class="nv">Forever</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Wait</span> <span class="p">(</span><span class="nv">Mode</span> <span class="p">: </span><span class="nv">Termination</span> <span class="p">:=</span> <span class="nv">No_Server</span><span class="p">);</span>
<span class="c1">-- The purpose of this procedure is to control the main procedure</span>
<span class="c1">-- termination. This procedure will return only when no server are running</span>
<span class="c1">-- (No_Server mode) or the 'q' key has been pressed. If mode is set to</span>
<span class="c1">-- Forever, Wait will never return and the process will have to be killed.</span>
<span class="c1">--------------------------</span>
<span class="c1">-- Server configuration --</span>
<span class="c1">--------------------------</span>
<span class="kd">function</span> <span class="nf">Config</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Config</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Returns configuration object for Web_Server</span>
<span class="kd">procedure</span> <span class="nf">Set_Unexpected_Exception_Handler</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Handler</span> <span class="p">: </span><span class="nv">Exceptions</span><span class="p">.</span><span class="nv">Unexpected_Exception_Handler</span><span class="p">);</span>
<span class="c1">-- Set the unexpected exception handler. It is called whenever an</span>
<span class="c1">-- unrecoverable error has been detected. The default handler just display</span>
<span class="c1">-- (on standard output) an error message with the location of the</span>
<span class="c1">-- error. By changing this handler it is possible to log or display full</span>
<span class="c1">-- symbolic stack backtrace if needed.</span>
<span class="kd">procedure</span> <span class="nf">Set</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Dynamically associate a new dispatcher object to the server. With the</span>
<span class="c1">-- feature it is possible to change server behavior at runtime. The</span>
<span class="c1">-- complete set of callback procedures will be changed when calling this</span>
<span class="c1">-- routine. Note that any change in a dispatcher associated with a server</span>
<span class="c1">-- using Register or Unregister must be reset into the server using this</span>
<span class="c1">-- routine.</span>
<span class="kd">procedure</span> <span class="nf">Set_Security</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Certificate_Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Security_Mode</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">SSL</span><span class="p">.</span><span class="nv">Method</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">SSL</span><span class="p">.</span><span class="nv">SSLv23_Server</span><span class="p">;</span>
<span class="nv">Key_Filename</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Set security option for AWS. Certificate_Filename is the name of a file</span>
<span class="c1">-- containing a certificate. Key_Filename is the name of the file</span>
<span class="c1">-- containing the key, if the empty string the key will be taken from the</span>
<span class="c1">-- certificate filename. This must be called before starting the secure</span>
<span class="c1">-- server otherwise the default security options or options set in the</span>
<span class="c1">-- config files will be used. After that the call will have no effect.</span>
<span class="kd">procedure</span> <span class="nf">Set_SSL_Config</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span> <span class="nv">SSL_Config</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">SSL</span><span class="p">.</span><span class="nv">Config</span><span class="p">);</span>
<span class="c1">-- Set the SSL configuration for this server</span>
<span class="kd">function</span> <span class="nf">SSL_Config</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span> <span class="n">Net</span><span class="p">.</span><span class="n">SSL</span><span class="p">.</span><span class="n">Config</span><span class="p">;</span>
<span class="c1">-- Returns the access to SSL config of the server. Allow to change SSL</span>
<span class="c1">-- config on the already created server.</span>
<span class="kd">procedure</span> <span class="nf">Set_Socket_Constructor</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Socket_Constructor</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Constructor</span><span class="p">);</span>
<span class="c1">-- Set the socket constructor routine to use when creating new sockets on</span>
<span class="c1">-- the server. By calling this routine it is possible to replace the</span>
<span class="c1">-- default AWS communication layer used. The default constructor is</span>
<span class="c1">-- AWS.Net.Socket. Note that this routine must be called before starting</span>
<span class="c1">-- the server. It is also important to note that sockets returned by the</span>
<span class="c1">-- constructor must have the cache properly initialized. See AWS.Net.Cache</span>
<span class="c1">-- for more information.</span>
<span class="kd">type</span> <span class="kt">HTTP_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">HTTP</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Get_Current</span> <span class="nf">return</span> <span class="nf">not</span> <span class="nf">null</span> <span class="nf">access</span> <span class="nf">HTTP</span><span class="p">;</span>
<span class="c1">-- Get current server. This can be used in a callback procedure to</span>
<span class="c1">-- retrieve the running HTTP server. It is needed when a callback</span>
<span class="c1">-- procedure is shared by multiple servers.</span>
<span class="kd">function</span> <span class="nf">Get_Status</span> <span class="nf">return</span> <span class="nf">Status</span><span class="p">.</span><span class="nf">Data</span><span class="p">;</span>
<span class="c1">-- Returns the current status data. This is useful to get the full status</span>
<span class="c1">-- in a templates engine callback procedure for example.</span>
<span class="kd">function</span> <span class="nf">Session_Name</span> <span class="nf">return</span> <span class="nf">String</span><span class="p">;</span>
<span class="c1">-- Returns the current session cookie name</span>
<span class="c1">---------------</span>
<span class="c1">-- Other API --</span>
<span class="c1">---------------</span>
<span class="kd">procedure</span> <span class="nf">Give_Back_Socket</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span> <span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Give the socket back to the server. Socket must have been taken from</span>
<span class="c1">-- the server using the Response.Socket_Taken routine in a callback.</span>
<span class="kd">procedure</span> <span class="nf">Give_Back_Socket</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Idem.</span>
<span class="c1">-- Use Socket_Access to avoid memory reallocation for already allocated</span>
<span class="c1">-- sockets.</span>
<span class="kd">procedure</span> <span class="nf">Set_Field</span> <span class="p">(</span><span class="nv">Id</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the extended log field value for the server the controlling the</span>
<span class="c1">-- current task.</span>
<span class="kd">procedure</span> <span class="nf">Skip_Log_Record</span><span class="p">;</span>
<span class="c1">-- Disable logging only for the current processing request</span>
<span class="kd">procedure</span> <span class="nf">Add_Listening</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">;</span>
<span class="nv">Family</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Family_Type</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Family_Unspec</span><span class="p">;</span>
<span class="nv">Reuse_Address</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">Host</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Add the binded/listening socket on host, port and protocol family. To be</span>
<span class="c1">-- able to connect web enabled application with others in the internal</span>
<span class="c1">-- network, and then give access for external clients by listening on</span>
<span class="c1">-- externally available address. Also it could be used to bind one server</span>
<span class="c1">-- to IPv4 and IPv6 protocols simultaneously.</span>
<span class="kd">type</span> <span class="kt">Task_Id_Array</span> <span class="kr">is</span>
<span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Ada</span><span class="p">.</span><span class="kd">Task</span><span class="mi">_</span><span class="n">Identification</span><span class="p">.</span><span class="kd">Task</span><span class="mi">_</span><span class="n">Id</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Line_Tasks</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kd">Task</span><span class="mi">_</span><span class="n">Id_Array</span><span class="p">;</span>
<span class="c1">-- Returns line tasks identifiers</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Server</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-server-hotplug">
<span id="id46"></span><h2>13.46. AWS.Server.Hotplug<a class="headerlink" href="#aws-server-hotplug" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-48"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Hotplug</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Server.Hotplug</span> <span class="kr">is</span>
<span class="c1">-- Messages used to register/unregister hotplug modules</span>
<span class="no">Register_Message</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"REGISTER"</span><span class="p">;</span>
<span class="no">Unregister_Message</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"UNREGISTER"</span><span class="p">;</span>
<span class="no">Request_Nonce_Message</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"REQUEST_NONCE"</span><span class="p">;</span>
<span class="c1">-- The Authorization_File below is a file that contains authorizations</span>
<span class="c1">-- for the hotplug modules. Only modules that have an entry into this</span>
<span class="c1">-- file will be able to register to server. Each line on this file must</span>
<span class="c1">-- have the following format:</span>
<span class="c1">--</span>
<span class="c1">-- <module_name>:<md5_password>:<host>:<port></span>
<span class="c1">--</span>
<span class="c1">-- module_name : The name of the module that will register</span>
<span class="c1">-- md5_password : The corresponding password, use aws_password</span>
<span class="c1">-- tool to generate such password</span>
<span class="c1">-- host : The host name where requests will be redirected</span>
<span class="c1">-- port : and the corresponding port</span>
<span class="kd">procedure</span> <span class="nf">Activate</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Authorization_File</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Register_Mode</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Hotplug</span><span class="p">.</span><span class="nv">Register_Mode</span> <span class="p">:=</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Hotplug</span><span class="p">.</span><span class="nv">Add</span><span class="p">;</span>
<span class="nv">Host</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Start hotplug server listening at the specified Port for the Web_Server.</span>
<span class="c1">-- Only client modules listed in the authorization file will be able to</span>
<span class="c1">-- connect to this server. For better securite the host of redictection</span>
<span class="c1">-- must also be specified.</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span><span class="p">;</span>
<span class="c1">-- Shutdown hotplug server</span>
<span class="kr">end</span> <span class="nf">AWS.Server.Hotplug</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-server-log">
<span id="id47"></span><h2>13.47. AWS.Server.Log<a class="headerlink" href="#aws-server-log" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-49"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Log</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Server.Log</span> <span class="kr">is</span>
<span class="c1">------------------</span>
<span class="c1">-- Standard Log --</span>
<span class="c1">------------------</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Split_Mode</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">Split_Mode</span> <span class="p">:=</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">None</span><span class="p">;</span>
<span class="nv">Filename_Prefix</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Auto_Flush</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Activate server's logging activity. See AWS.Log. If Auto_Flush is True</span>
<span class="c1">-- the file will be flushed after all written data.</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Callback</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Activate the Web_Server access log and direct all data to the Callback.</span>
<span class="c1">-- The Name String is returned when the Name function is called. It is a</span>
<span class="c1">-- simple identifier, that serves no other purpose than to give the</span>
<span class="c1">-- Callback a label.</span>
<span class="kd">function</span> <span class="nf">Name</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Return the name of the Log or an empty string if one is not active. If</span>
<span class="c1">-- an external writer is used to handle the access log, then the name of</span>
<span class="c1">-- that writer is returned. See the Start procedure for starting the access</span>
<span class="c1">-- log with a Callback.</span>
<span class="kd">procedure</span> <span class="nf">Stop</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">);</span>
<span class="c1">-- Stop server's logging activity. See AWS.Log</span>
<span class="kd">function</span> <span class="nf">Is_Active</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the Web Server log has been activated</span>
<span class="kd">procedure</span> <span class="nf">Flush</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">);</span>
<span class="c1">-- Flush the server log.</span>
<span class="c1">-- Note that error log does not need to be flushed because it is always</span>
<span class="c1">-- flushed by default. If a Callback procedure is used to handle the log</span>
<span class="c1">-- data, then calling Flush does nothing.</span>
<span class="c1">---------------</span>
<span class="c1">-- Error Log --</span>
<span class="c1">---------------</span>
<span class="kd">procedure</span> <span class="nf">Start_Error</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Split_Mode</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">Split_Mode</span> <span class="p">:=</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">None</span><span class="p">;</span>
<span class="nv">Filename_Prefix</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Activate server's logging activity. See AWS.Log</span>
<span class="kd">procedure</span> <span class="nf">Start_Error</span>
<span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">;</span>
<span class="nv">Callback</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Log</span><span class="p">.</span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Activate the Web_Server error log and direct all data to the Callback.</span>
<span class="c1">-- The Name String is returned when the Error_Name function is called. It</span>
<span class="c1">-- is a simple identifier, that serves no other purpose than to give the</span>
<span class="c1">-- Callback a label.</span>
<span class="kd">function</span> <span class="nf">Error_Name</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Return the name of the Error Log or an empty string if one is not</span>
<span class="c1">-- active. If a Callback is used to handle the error log, then the name of</span>
<span class="c1">-- the Callback is returned. See the Start_Error procedure for starting the</span>
<span class="c1">-- error log with a Callback.</span>
<span class="kd">procedure</span> <span class="nf">Stop_Error</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">HTTP</span><span class="p">);</span>
<span class="c1">-- Stop server's logging activity. See AWS.Log</span>
<span class="kd">function</span> <span class="nf">Is_Error_Active</span> <span class="p">(</span><span class="nv">Web_Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the Web Server error log has been activated</span>
<span class="kr">end</span> <span class="nf">AWS.Server.Log</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-server-push">
<span id="id48"></span><h2>13.48. AWS.Server.Push<a class="headerlink" href="#aws-server-push" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-50"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2017, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Package to support Server Push feature. This is only supported by Netscape</span>
<span class="c1">-- browsers. It will not work with Microsoft Internet Explorer.</span>
<span class="c1">-- For Microsoft Internet Explorer complementary active components</span>
<span class="c1">-- should be used like java applets or ActiveX controls.</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Containers.Tables</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Default</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">System</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Hashed_Sets</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Hashed_Maps</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Doubly_Linked_Lists</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Hash</span><span class="p">;</span>
<span class="kd">generic</span>
<span class="kd">type</span> <span class="kt">Client_Output_Type</span> <span class="p">(<>)</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Data type client want to send through server push</span>
<span class="kd">type</span> <span class="kt">Client_Environment</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Data type to keep client context. This context will be passed to the</span>
<span class="c1">-- conversion routine below.</span>
<span class="kn">with</span> <span class="nn">function</span> <span class="n">To_Stream_Array</span>
<span class="p">(</span><span class="n">Output</span> <span class="p">:</span> <span class="n">Client_Output_Type</span><span class="p">;</span>
<span class="n">Client</span> <span class="p">:</span> <span class="n">Client_Environment</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Streams</span><span class="p">.</span><span class="n">Stream_Element_Array</span><span class="p">;</span>
<span class="c1">-- Function used for convert Client_Output_Type to Stream_Output_Type.</span>
<span class="c1">-- This is used by the server to prepare the data to be sent to the</span>
<span class="c1">-- clients.</span>
<span class="kd">package</span> <span class="nc">AWS.Server.Push</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">Client_Gone</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when a client is not responding</span>
<span class="n">Closed</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when trying to register to a closed push server</span>
<span class="n">Duplicate_Client_Id</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised in trying to register an already registered client</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- This is the push server object. A push server has two modes, either it</span>
<span class="c1">-- is Open or Closed. When open it will send data to registered</span>
<span class="c1">-- clients. No data will be sent to registered client if the server is</span>
<span class="c1">-- Closed.</span>
<span class="kd">type</span> <span class="kt">Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Plain</span><span class="p">,</span> <span class="nv">Multipart</span><span class="p">,</span> <span class="nv">Chunked</span><span class="p">);</span>
<span class="c1">-- Described the mode to communicate with the client.</span>
<span class="c1">-- Plain : no transformation is done, the data are sent as-is</span>
<span class="c1">-- Multipart : data are MIME encoded.</span>
<span class="c1">-- Chuncked : data are chunked, a piece of data is sent in small pieces.</span>
<span class="kd">subtype</span> <span class="kt">Client_Key</span> <span class="kr">is</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- The Client Id key representation. In a server each client must have a</span>
<span class="c1">-- uniq ID. This Id is used for registration and for sending data to</span>
<span class="c1">-- specific client.</span>
<span class="kd">type</span> <span class="kt">Wait_Counter_Type</span> <span class="kr">is</span> <span class="ow">mod</span> <span class="n">System</span><span class="p">.</span><span class="n">Max_Binary_Modulus</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Group_Set</span> <span class="kr">is</span> <span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">VString_Array</span><span class="p">;</span>
<span class="no">Empty_Group</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Group_Set</span> <span class="p">:=</span> <span class="p">(</span><span class="mi">1</span> <span class="p">..</span> <span class="mi">0</span> <span class="p">=></span> <span class="n">Null_Unbounded_String</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Access</span><span class="p">;</span>
<span class="nv">Environment</span> <span class="p">: </span><span class="nv">Client_Environment</span><span class="p">;</span>
<span class="nv">Init_Data</span> <span class="p">: </span><span class="nv">Client_Output_Type</span><span class="p">;</span>
<span class="nv">Init_Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Kind</span> <span class="p">: </span><span class="nv">Mode</span> <span class="p">:=</span> <span class="nv">Plain</span><span class="p">;</span>
<span class="nv">Duplicated_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Duration</span><span class="p">'</span><span class="na">Last</span><span class="p">;</span>
<span class="nv">Groups</span> <span class="p">: </span><span class="nv">Group_Set</span> <span class="p">:=</span> <span class="nv">Empty_Group</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Send_Timeout</span><span class="p">);</span>
<span class="c1">-- Add client identified by Client_Id to the server subscription</span>
<span class="c1">-- list and send the Init_Data (as a Init_Content_Type mime content) to</span>
<span class="c1">-- him. After registering this client will be able to receive pushed data</span>
<span class="c1">-- from the server in broadcasting mode.</span>
<span class="c1">-- If Duplicated_Age less than age of the already registered same Client_Id</span>
<span class="c1">-- then old one will be unregistered first (no exception will be raised).</span>
<span class="c1">-- The Timeout is not for socket send timeout, but for internal waiting for</span>
<span class="c1">-- write availability timeout.</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Environment</span> <span class="p">: </span><span class="nv">Client_Environment</span><span class="p">;</span>
<span class="nv">Init_Data</span> <span class="p">: </span><span class="nv">Client_Output_Type</span><span class="p">;</span>
<span class="nv">Init_Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Kind</span> <span class="p">: </span><span class="nv">Mode</span> <span class="p">:=</span> <span class="nv">Plain</span><span class="p">;</span>
<span class="nv">Duplicated_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Duration</span><span class="p">'</span><span class="na">Last</span><span class="p">;</span>
<span class="nv">Groups</span> <span class="p">: </span><span class="nv">Group_Set</span> <span class="p">:=</span> <span class="nv">Empty_Group</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Send_Timeout</span><span class="p">);</span>
<span class="c1">-- Same as above but with Socket_Type'Class parameter.</span>
<span class="c1">-- Is not recommended, use above one with Socket_Access parameter.</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span>
<span class="nv">Socket</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Environment</span> <span class="p">: </span><span class="nv">Client_Environment</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Kind</span> <span class="p">: </span><span class="nv">Mode</span> <span class="p">:=</span> <span class="nv">Plain</span><span class="p">;</span>
<span class="nv">Duplicated_Age</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Duration</span><span class="p">'</span><span class="na">Last</span><span class="p">;</span>
<span class="nv">Groups</span> <span class="p">: </span><span class="nv">Group_Set</span> <span class="p">:=</span> <span class="nv">Empty_Group</span><span class="p">;</span>
<span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Default</span><span class="p">.</span><span class="nv">Send_Timeout</span><span class="p">);</span>
<span class="c1">-- Same as above but without sending initial data.</span>
<span class="c1">-- Content_Type applicable only when Kind parameter is Plain or Chunked,</span>
<span class="c1">-- in Multipart server push mode each server push message would have own</span>
<span class="c1">-- Content_Type defined.</span>
<span class="c1">-- Is not recommended, use above one with Socket_Access parameter.</span>
<span class="kd">procedure</span> <span class="nf">Unregister</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span>
<span class="nv">Close_Socket</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">);</span>
<span class="c1">-- Removes client Client_Id from server subscription list. The associated</span>
<span class="c1">-- client's socket will be closed if Close_Socket is True. No exception is</span>
<span class="c1">-- raised if Client_Id was not registered.</span>
<span class="kd">procedure</span> <span class="nf">Unregister_Clients</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Close_Sockets</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">);</span>
<span class="c1">-- Remove all registered clients from the server. Closes if Close_Sockets</span>
<span class="c1">-- is set to True (default) otherwise the sockets remain open. After this</span>
<span class="c1">-- call the sever will still in running mode. Does nothing if there is no</span>
<span class="c1">-- client registered.</span>
<span class="kd">procedure</span> <span class="nf">Subscribe</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span> <span class="nv">Group_Id</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Subscribe client to the group</span>
<span class="kd">procedure</span> <span class="nf">Subscribe_Copy</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Source</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Target</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Subscribe everybody in the group Source to the group Target.</span>
<span class="c1">-- If Source is empty then subscribe all clients to the group Target.</span>
<span class="kd">procedure</span> <span class="nf">Unsubscribe</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span> <span class="nv">Group_Id</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Remove group from client's group list</span>
<span class="kd">procedure</span> <span class="nf">Unsubscribe_Copy</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Source</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Target</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Unsubscribe everybody in the group Source from the group Target.</span>
<span class="c1">-- If Source is empty then unsubscribe all clients from the group Target.</span>
<span class="kd">procedure</span> <span class="nf">Send_To</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Client_Output_Type</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Thin_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Push data to a specified client identified by Client_Id</span>
<span class="c1">-- Thin_Id is to be able to replace messages in the send client queue</span>
<span class="c1">-- with the newer one with the same Thin_Id.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Client_Output_Type</span><span class="p">;</span>
<span class="nv">Group_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Thin_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Client_Gone</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">procedure</span> <span class="p">(</span><span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="p">:=</span> <span class="kc">null</span><span class="p">);</span>
<span class="c1">-- Push data to group of clients (broadcast) subscribed to the server.</span>
<span class="c1">-- If Group_Id is empty, data transferred to each client.</span>
<span class="c1">-- Call Client_Gone for each client with broken socket.</span>
<span class="c1">-- Thin_Id is to be able to replace messages in the send client queue</span>
<span class="c1">-- with the newer one with the same Thin_Id.</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Client_Gone</span> <span class="p">(</span><span class="n">Client_Id</span> <span class="p">:</span> <span class="kt">String</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Send_G</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">Client_Output_Type</span><span class="p">;</span>
<span class="nv">Group_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Thin_Id</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Same like before, but generic for back compatibility</span>
<span class="kd">function</span> <span class="nf">Count</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of registered clients in the server</span>
<span class="kd">procedure</span> <span class="nf">Info</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Clients</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Natural</span><span class="p">;</span>
<span class="nv">Groups</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Natural</span><span class="p">;</span>
<span class="nv">Process</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">procedure</span>
<span class="p">(</span><span class="nv">Client_Id</span> <span class="p">: </span><span class="nv">Client_Key</span><span class="p">;</span>
<span class="nv">Address</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">State</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Environment</span> <span class="p">: </span><span class="nv">Client_Environment</span><span class="p">;</span>
<span class="nv">Kind</span> <span class="p">: </span><span class="nv">Mode</span><span class="p">;</span>
<span class="nv">Groups</span> <span class="p">: </span><span class="nv">Group_Set</span><span class="p">)</span> <span class="p">:=</span> <span class="kc">null</span><span class="p">);</span>
<span class="c1">-- Returns the number of registered clients and groups in the server.</span>
<span class="c1">-- Call Process routine for each client if defined.</span>
<span class="c1">-- Test internal integrity.</span>
<span class="kd">function</span> <span class="nf">Is_Open</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Return True if the server is open, meaning server is still running,</span>
<span class="c1">-- ready to accept client's registration and still sending data to</span>
<span class="c1">-- clients.</span>
<span class="c1">-- Shutdown routines put the server in a Closed mode. The routines below</span>
<span class="c1">-- provides a way to eventually close the socket, to send some</span>
<span class="c1">-- finalization data.</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Close_Sockets</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">);</span>
<span class="c1">-- Unregistered all clients and close all associated connections (socket)</span>
<span class="c1">-- if Close_Socket is True. The server will be in Closed mode. After this</span>
<span class="c1">-- call any client trying to register will get the Closed exception. It is</span>
<span class="c1">-- possible to reactivate the server with Restart.</span>
<span class="kd">procedure</span> <span class="nf">Shutdown</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Final_Data</span> <span class="p">: </span><span class="nv">Client_Output_Type</span><span class="p">;</span>
<span class="nv">Final_Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Idem as above but it send Final_Data (as a Data_Content_Type mime</span>
<span class="c1">-- content) before closing connections.</span>
<span class="kd">procedure</span> <span class="nf">Shutdown_If_Empty</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Open</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Server will be shutdown (close mode) if there is no more active clients</span>
<span class="c1">-- (Count = 0). Returns new server status in Open (Open will be True if</span>
<span class="c1">-- server is in Open mode and False otherwise). After this call any client</span>
<span class="c1">-- trying to register will get the Closed exception. It is possible to</span>
<span class="c1">-- reactivate the server with Restart.</span>
<span class="kd">procedure</span> <span class="nf">Restart</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Set server to Open mode. Server will again send data to registered</span>
<span class="c1">-- clients. It does nothing if server was already open.</span>
<span class="kd">procedure</span> <span class="nf">Info</span>
<span class="p">(</span><span class="nv">Size</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Natural</span><span class="p">;</span>
<span class="nv">Max_Size</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Natural</span><span class="p">;</span>
<span class="nv">Max_Size_DT</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Calendar</span><span class="p">.</span><span class="nv">Time</span><span class="p">;</span>
<span class="nv">Counter</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Wait_Counter_Type</span><span class="p">);</span>
<span class="c1">-- Size would return number of currently waiting sockets.</span>
<span class="c1">-- Counter would return total number of waited sockets from start.</span>
<span class="kd">function</span> <span class="nf">Wait_Send_Completion</span> <span class="p">(</span><span class="nv">Timeout</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Wait for all data sending in all server_push objects of the current</span>
<span class="c1">-- package instance.</span>
<span class="c1">-- Return True if wait successful. False in timeout.</span>
<span class="kd">type</span> <span class="kt">Error_Handler</span> <span class="kr">is</span> <span class="ow">not</span> <span class="kc">null</span> <span class="kr">access</span> <span class="kd">procedure</span> <span class="p">(</span><span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">Set_Internal_Error_Handler</span> <span class="p">(</span><span class="nv">Handler</span> <span class="p">: </span><span class="nv">Error_Handler</span><span class="p">);</span>
<span class="c1">-- Set the handler of the internal fatal errors</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Server.Push</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-server-status">
<span id="id49"></span><h2>13.49. AWS.Server.Status<a class="headerlink" href="#aws-server-status" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-51"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- This package provides routine to retrieve server's internal status</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net.Acceptors</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Templates</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Server.Status</span> <span class="kr">is</span>
<span class="kd">function</span> <span class="nf">Translations</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span><span class="p">;</span>
<span class="c1">-- Returns a translate table to be used with a template file. This table</span>
<span class="c1">-- contains all internal server's data. This table is used by the server</span>
<span class="c1">-- internal status page for example.</span>
<span class="kd">function</span> <span class="nf">Translations</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Table</span><span class="p">;</span>
<span class="kr">pragma</span> <span class="cp">Obsolescent</span> <span class="p">(</span><span class="s">"Use Translate_Set return value instead"</span><span class="p">);</span>
<span class="c1">-- The same as above but obsolete and keept for backward compartibility</span>
<span class="kd">function</span> <span class="nf">Start_Time</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="c1">-- Returns the server's start time</span>
<span class="kd">function</span> <span class="nf">Resources_Served</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the total number of resources (static file, templates,</span>
<span class="c1">-- in-memory string) served by the server.</span>
<span class="kd">function</span> <span class="nf">Socket</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Net</span><span class="p">.</span><span class="n">Socket_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Returns the main server's socket</span>
<span class="kd">function</span> <span class="nf">Sockets</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Net</span><span class="p">.</span><span class="n">Acceptors</span><span class="p">.</span><span class="n">Socket_List</span><span class="p">;</span>
<span class="c1">-- Returns all server's sockets</span>
<span class="kd">function</span> <span class="nf">Port</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="c1">-- Returns the server's socket port</span>
<span class="kd">function</span> <span class="nf">Host</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the server's socket host</span>
<span class="kd">function</span> <span class="nf">Is_Any_Address</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the server accepts connections on any of the host's</span>
<span class="c1">-- network addresses.</span>
<span class="kd">function</span> <span class="nf">Is_IPv6</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if Server is using IPv6</span>
<span class="kd">function</span> <span class="nf">Local_URL</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Local URL of the server</span>
<span class="kd">function</span> <span class="nf">Current_Connections</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the current number of connections</span>
<span class="kd">function</span> <span class="nf">Is_Session_Activated</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the session feature has been activated</span>
<span class="kd">function</span> <span class="nf">Is_Security_Activated</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the HTTPS protocol is used</span>
<span class="kd">function</span> <span class="nf">Is_Shutdown</span> <span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">HTTP</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if server has been stopped (the server could still be in</span>
<span class="c1">-- the shutdown phase).</span>
<span class="kr">end</span> <span class="nf">AWS.Server.Status</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-callbacks">
<span id="id50"></span><h2>13.50. AWS.Services.Callbacks<a class="headerlink" href="#aws-services-callbacks" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-52"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Services to be used to declare aliases based on URI. This is mostly</span>
<span class="c1">-- designed to be used with AWS.services.Dispatchers.URI.</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Callbacks</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">AWS</span><span class="p">;</span>
<span class="kd">generic</span>
<span class="n">Prefix</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span> <span class="c1">-- the prefix found in the URI</span>
<span class="n">Directory</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span> <span class="c1">-- the directory where the file is</span>
<span class="kd">function</span> <span class="nf">File</span> <span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- This is a callback function where URL:</span>
<span class="c1">-- http://<host>/<prefix>toto</span>
<span class="c1">-- references the file:</span>
<span class="c1">-- <directory>/toto</span>
<span class="c1">--</span>
<span class="c1">-- If the URL does not start with Prefix it returns a 404 error page.</span>
<span class="c1">-- This is designed to be use with AWS.Services.Dispatchers.URI.</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Callbacks</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-directory">
<span id="id51"></span><h2>13.51. AWS.Services.Directory<a class="headerlink" href="#aws-services-directory" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-53"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Templates_Parser</span><span class="p">;</span>
<span class="c1">-- This service can be used to browse a file system. The browsing mechanism</span>
<span class="c1">-- will gather information (filename, size, directory...) from a specified</span>
<span class="c1">-- directory name and will fill a translation table. This table will be used</span>
<span class="c1">-- with a template file to render the HTML document. You can design your own</span>
<span class="c1">-- browsing template file, here is a description of all tag variables defined</span>
<span class="c1">-- in the translation table:</span>
<span class="c1">--</span>
<span class="c1">-- URI (discrete)</span>
<span class="c1">-- The URI pointing to the directory parsed.</span>
<span class="c1">--</span>
<span class="c1">-- VERSION (discrete)</span>
<span class="c1">-- AWS version string.</span>
<span class="c1">--</span>
<span class="c1">-- IS_DIR_V (vector)</span>
<span class="c1">-- A list of booleans, indicate if Nth entry is a directory or not.</span>
<span class="c1">--</span>
<span class="c1">-- NAME_V (vector)</span>
<span class="c1">-- A list of filenames. Nth name is a directory if Nth entry in IS_DIR</span>
<span class="c1">-- is set to true.</span>
<span class="c1">--</span>
<span class="c1">-- SIZE_V (vector)</span>
<span class="c1">-- A list of sizes. Nth entry is the file size of the Nth entry in</span>
<span class="c1">-- NAMES.</span>
<span class="c1">--</span>
<span class="c1">-- TIME_V (vector)</span>
<span class="c1">-- A list of last modification times. Nth entry is is the last</span>
<span class="c1">-- modification time of the Nth entry in NAMES.</span>
<span class="c1">--</span>
<span class="c1">-- NAME_ORDR</span>
<span class="c1">-- Rule to either set ordering on name or to revert current name</span>
<span class="c1">-- ordering.</span>
<span class="c1">--</span>
<span class="c1">-- SNME_ORDR</span>
<span class="c1">-- Rule to either set ordering on name (case sensitive) or to revert</span>
<span class="c1">-- current name (case sensitive) ordering.</span>
<span class="c1">--</span>
<span class="c1">-- EXT_ORDR</span>
<span class="c1">-- Rule to either set ordering on extension or to revert current</span>
<span class="c1">-- extension ordering.</span>
<span class="c1">--</span>
<span class="c1">-- SEXT_ORDR</span>
<span class="c1">-- Rule to either set ordering on extension (case sensitive) or to</span>
<span class="c1">-- revert current extension (case sensitive) ordering.</span>
<span class="c1">--</span>
<span class="c1">-- MIME_ORDR</span>
<span class="c1">-- Rule to either set ordering on MIME type or to revert current MIME</span>
<span class="c1">-- type ordering.</span>
<span class="c1">--</span>
<span class="c1">-- DIR_ORDR</span>
<span class="c1">-- Rule to either set ordering on directory or to revert current</span>
<span class="c1">-- directory ordering.</span>
<span class="c1">--</span>
<span class="c1">-- SIZE_ORDR</span>
<span class="c1">-- Rule to either set ordering on size or to revert current size</span>
<span class="c1">-- ordering.</span>
<span class="c1">--</span>
<span class="c1">-- TIME_ORDR</span>
<span class="c1">-- Rule to either set ordering on time or to revert current time</span>
<span class="c1">-- ordering.</span>
<span class="c1">--</span>
<span class="c1">-- ORIG_ORDR</span>
<span class="c1">-- Rule to either set original ordering (file order as read on the file</span>
<span class="c1">-- system) or to revert current original ordering.</span>
<span class="c1">--</span>
<span class="c1">-- DIR_NAME_ORDR</span>
<span class="c1">-- Rule to either set ordering on directory/name or to revert current</span>
<span class="c1">-- directory/name ordering.</span>
<span class="c1">--</span>
<span class="c1">-- DIR_SNME_ORDR</span>
<span class="c1">-- Rule to either set ordering on directory/name (case sensitive) or to</span>
<span class="c1">-- revert current directory/name (case sensitive) ordering.</span>
<span class="c1">--</span>
<span class="c1">-- DIR_TIME_ORDR</span>
<span class="c1">-- Rule to either set ordering on directory/time or to revert current</span>
<span class="c1">-- directory/time ordering.</span>
<span class="c1">--</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Directory</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Templates_Parser</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Browse</span>
<span class="p">(</span><span class="nv">Directory_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Translate_Set</span><span class="p">;</span>
<span class="c1">-- Returns a translation table containing information parsed from</span>
<span class="c1">-- Directory_Name. This is supposed to be used with a directory template.</span>
<span class="kd">function</span> <span class="nf">Browse</span>
<span class="p">(</span><span class="nv">Directory_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Template_Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">Translate_Set</span> <span class="p">:=</span> <span class="nv">Null_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Parses directory Directory_Name and use Templates_Parser to fill in the</span>
<span class="c1">-- template Template_Filename. It is possible to specified some specifics</span>
<span class="c1">-- tags in Translations.</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Directory</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-dispatchers">
<span id="id52"></span><h2>13.52. AWS.Services.Dispatchers<a class="headerlink" href="#aws-services-dispatchers" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-54"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Dispatchers</span> <span class="nc">with</span> <span class="nc">Pure</span> <span class="kr">is</span>
<span class="c1">-- Services on the Dispatcher tree are to help building big servers.</span>
<span class="c1">-- Experiences shows that a lot of user's code is to check the value of a</span>
<span class="c1">-- specific URI or request method to call the right callback that will</span>
<span class="c1">-- handle the request. This code is a big "if/elsif/end if" that just hide</span>
<span class="c1">-- the real job. A dispatcher is to replace this code. Currently there is</span>
<span class="c1">-- five of them:</span>
<span class="c1">--</span>
<span class="c1">-- URI (AWS.Services.Dispatchers.URI)</span>
<span class="c1">-- to dispatch to a callback depending of the resource name.</span>
<span class="c1">--</span>
<span class="c1">-- Method (AWS.Services.Dispatchers.Method)</span>
<span class="c1">-- to dispatch to a callback depending of the request method.</span>
<span class="c1">--</span>
<span class="c1">-- Virtual_Host (AWS.Services.Dispatchers.Virtual_Host)</span>
<span class="c1">-- to dispatch to a callback depending on the host name. This is known</span>
<span class="c1">-- as virtual hosting and permit to have multiple servers on the same</span>
<span class="c1">-- machine using the same port.</span>
<span class="c1">--</span>
<span class="c1">-- Transient_Pages (AWS.Services.Dispatchers.Transient_Pages)</span>
<span class="c1">-- to handle transient pages, if the default user's callback returns</span>
<span class="c1">-- 404 this dispatcher checks if the requested resource is a transient</span>
<span class="c1">-- page.</span>
<span class="c1">--</span>
<span class="c1">-- Timer (AWS.Services.Dispatchers.Timer)</span>
<span class="c1">-- to dispatch to a specific callback depending on the current time.</span>
<span class="c1">--</span>
<span class="c1">-- Linker (AWS.Services.Dispatchers.Linker)</span>
<span class="c1">-- to link two dispatchers together, if the first one retruns 404 tries</span>
<span class="c1">-- the second one.</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Dispatchers</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-dispatchers-linker">
<span id="id53"></span><h2>13.53. AWS.Services.Dispatchers.Linker<a class="headerlink" href="#aws-services-dispatchers-linker" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-55"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2005-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Link two dispatchers together</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Dispatchers.Linker</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">First</span><span class="p">,</span> <span class="nv">Second</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Set the dispatcher first and second handler. The First handler will be</span>
<span class="c1">-- looked for before the second.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Dispatchers.Linker</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-dispatchers-method">
<span id="id54"></span><h2>13.54. AWS.Services.Dispatchers.Method<a class="headerlink" href="#aws-services-dispatchers-method" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-56"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Dispatch a specific request to a callback depending on the request method</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Dispatchers.Method</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Method</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Request_Method</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Register callback to use for a specific request method</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Method</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Request_Method</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">);</span>
<span class="c1">-- Idem as above but take a callback procedure as parameter</span>
<span class="kd">procedure</span> <span class="nf">Unregister</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Method</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Request_Method</span><span class="p">);</span>
<span class="c1">-- Removes Method from the list of request method to handle</span>
<span class="kd">procedure</span> <span class="nf">Register_Default_Callback</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Register the default callback. This will be used if no request method</span>
<span class="c1">-- have been activated.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Dispatchers.Method</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-dispatchers-uri">
<span id="id55"></span><h2>13.55. AWS.Services.Dispatchers.URI<a class="headerlink" href="#aws-services-dispatchers-uri" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-57"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Dispatch a specific request to a callback depending on the URI</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Vectors</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Dispatchers.URI</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Prefix</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Register URI to use the specified dispatcher. URI is the full string</span>
<span class="c1">-- that must match the resource requested (with the leading /). If Prefix</span>
<span class="c1">-- is True, only the URI prefix is checked.</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">Prefix</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Idem as above but take a callback procedure as parameter</span>
<span class="kd">procedure</span> <span class="nf">Register_Regexp</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Register URI to use the specified dispatcher. URI is a regular</span>
<span class="c1">-- expression that must match the resource requested (with the leading /).</span>
<span class="kd">procedure</span> <span class="nf">Register_Regexp</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">);</span>
<span class="c1">-- Idem as above but take a callback procedure as parameter</span>
<span class="kd">procedure</span> <span class="nf">Unregister</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Removes URI from the list. URI is either a name or a regexp and must</span>
<span class="c1">-- have exactly the value used with Register.</span>
<span class="kd">procedure</span> <span class="nf">Register_Default_Callback</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Register the default callback. This will be used if no URI match</span>
<span class="c1">-- the request.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Dispatchers.URI</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-dispatchers-virtual-host">
<span id="id56"></span><h2>13.56. AWS.Services.Dispatchers.Virtual_Host<a class="headerlink" href="#aws-services-dispatchers-virtual-host" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-58"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Hashed_Maps</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Hash</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Dispatchers.Virtual_Host</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Virtual_Hostname</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Hostname</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Register Virtual_Hostname to be a redirection to the specified</span>
<span class="c1">-- hostname.</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Virtual_Hostname</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Register Virtual_Hostname to use the specified callback</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Virtual_Hostname</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">);</span>
<span class="c1">-- Idem as above but take a callback procedure as parameter</span>
<span class="kd">procedure</span> <span class="nf">Unregister</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Virtual_Hostname</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Removes Virtual_Hostname from the list of virtual hostnames to handle</span>
<span class="kd">procedure</span> <span class="nf">Register_Default_Callback</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Action</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">);</span>
<span class="c1">-- Register the default callback. This will be used if no Virtual_Hostname</span>
<span class="c1">-- match the request.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Dispatchers.Virtual_Host</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-download">
<span id="id57"></span><h2>13.57. AWS.Services.Download<a class="headerlink" href="#aws-services-download" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-59"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2005-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- This is a download manager service, can be used to avoid polluting the main</span>
<span class="c1">-- server slot with long downloads. A single task is used in this</span>
<span class="c1">-- implementation.</span>
<span class="kn">with</span> <span class="nn">AWS.Config</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Services.Dispatchers.Linker</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Download</span> <span class="kr">is</span>
<span class="kd">procedure</span> <span class="nf">Start</span>
<span class="p">(</span><span class="nv">Server_Dispatcher</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Handler</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Main_Dispatcher</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Services</span><span class="p">.</span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">Linker</span><span class="p">.</span><span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Max_Concurrent_Download</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Config</span><span class="p">.</span><span class="nv">Max_Concurrent_Download</span><span class="p">);</span>
<span class="c1">-- Start the download manager server. Server_Dispatcher is the dispatcher</span>
<span class="c1">-- for the Web server. Main_Dispatcher is the dispatcher that must be used</span>
<span class="c1">-- with the main server start routine. This dispatcher handles the standard</span>
<span class="c1">-- web server resources and the download manager ones.</span>
<span class="c1">-- Max_Concurrent_Download contains the number of simultaneous download</span>
<span class="c1">-- that can be handled, request past this limit are queued. Note that a</span>
<span class="c1">-- single task is used for this implementation. Using a download manager is</span>
<span class="c1">-- useful to avoid the standard Web server to be busy with long downloads.</span>
<span class="kd">procedure</span> <span class="nf">Stop</span><span class="p">;</span>
<span class="c1">-- Stop the download server, all current download are interrupted</span>
<span class="kd">function</span> <span class="nf">Build</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Resource</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">Resources</span><span class="p">.</span><span class="nv">Streams</span><span class="p">.</span><span class="nv">Stream_Type</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Queue a download request. If there is room on the download manager the</span>
<span class="c1">-- template page aws_download_manager_start.thtml is used to build the</span>
<span class="c1">-- answer otherwise the template page aws_download_manager_waiting.thtml is</span>
<span class="c1">-- used. Name is the resource name and will be the default name used on the</span>
<span class="c1">-- user side to save the file on disk. Resource is a stream on which the</span>
<span class="c1">-- data to be sent are read.</span>
<span class="c1">--</span>
<span class="c1">-- Templates tags description:</span>
<span class="c1">--</span>
<span class="c1">-- aws_download_manager_waiting.thtml</span>
<span class="c1">-- NAME the name of the resource as pass to build</span>
<span class="c1">-- RES_URI the resource URI unique to the download server</span>
<span class="c1">-- POSITION the position on the waiting queue</span>
<span class="c1">-- aws_download_manager_start.thtml</span>
<span class="c1">-- NAME the name of the resource as pass to build</span>
<span class="c1">-- RES_URI the resource URI unique to the download server</span>
<span class="c1">--</span>
<span class="c1">-- Note that both template pages must contain a refresh meta-tag:</span>
<span class="c1">--</span>
<span class="c1">-- <meta http-equiv="refresh" content="2"></span>
<span class="kr">end</span> <span class="nf">AWS.Services.Download</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-page-server">
<span id="id58"></span><h2>13.58. AWS.Services.Page_Server<a class="headerlink" href="#aws-services-page-server" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-60"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- The Callback is an implementation of a simple static Web page server. It</span>
<span class="c1">-- will return the Web pages found in the Web server directory. If directory</span>
<span class="c1">-- browsing is activated, it will be possible to browse directory content if</span>
<span class="c1">-- the requested resource is a directory. There is two specials files that</span>
<span class="c1">-- are recognized:</span>
<span class="c1">--</span>
<span class="c1">-- 404.thtml The Web page returned if the requested page is</span>
<span class="c1">-- not found. This is a template with a single tag</span>
<span class="c1">-- variable named PAGE. It will be replaced by the</span>
<span class="c1">-- resource which was not found.</span>
<span class="c1">--</span>
<span class="c1">-- Note that on Microsoft IE this page will be</span>
<span class="c1">-- displayed only if the total page size is bigger</span>
<span class="c1">-- than 512 bytes or it includes at least one</span>
<span class="c1">-- image.</span>
<span class="c1">--</span>
<span class="c1">-- aws_directory.thtml The template page used for directory browsing.</span>
<span class="c1">-- See AWS.Services.Directory for a full description</span>
<span class="c1">-- of this template usage.</span>
<span class="kn">with</span> <span class="nn">AWS.Messages</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Page_Server</span> <span class="kr">is</span>
<span class="kd">procedure</span> <span class="nf">Directory_Browsing</span> <span class="p">(</span><span class="nv">Activated</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- If Activated is set to True the directory browsing facility will be</span>
<span class="c1">-- activated. By default this feature is not activated.</span>
<span class="kd">procedure</span> <span class="nf">Set_Cache_Control</span> <span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Data</span><span class="p">);</span>
<span class="c1">-- Set the Cache-Control header for each response given by the following</span>
<span class="c1">-- callback.</span>
<span class="kd">function</span> <span class="nf">Callback</span> <span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- This is the AWS callback for the simple static Web pages server</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Page_Server</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-split-pages">
<span id="id59"></span><h2>13.59. AWS.Services.Split_Pages<a class="headerlink" href="#aws-services-split-pages" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-61"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Templates</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Split_Pages</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">Splitter_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- This package provides an API to split a big table in multiple pages</span>
<span class="c1">-- using the transient Web Pages support.</span>
<span class="kd">type</span> <span class="kt">Page_Range</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">First</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">Last</span> <span class="p">:</span> <span class="kt">Natural</span><span class="p">;</span> <span class="c1">-- For an empty range, Last < First</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Ranges_Table</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Page_Range</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">URI_Table</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Splitter</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">tagged</span> <span class="kr">limited</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- This is the (abstract) root class of all splitters</span>
<span class="c1">-- Two operations are necessary: Get_Page_Ranges and Get_Translations</span>
<span class="c1">-- The following tags are always defined by the Parse function; however,</span>
<span class="c1">-- if a splitter redefines them in Get_Translations, the new definition</span>
<span class="c1">-- will replace the standard one:</span>
<span class="c1">-- NUMBER_PAGES Number of pages generated.</span>
<span class="c1">-- PAGE_NUMBER Position of the current page in all pages</span>
<span class="c1">-- OFFSET Current table line offset real table line can be computed</span>
<span class="c1">-- using: @_"+"(OFFSET):TABLE_LINE_@</span>
<span class="kd">function</span> <span class="nf">Get_Page_Ranges</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ranges_Table</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Get_Page_Ranges is called to define the range (in lines) of each split</span>
<span class="c1">-- page. Note that the ranges may overlap and need not cover the full</span>
<span class="c1">-- table.</span>
<span class="kd">function</span> <span class="nf">Get_Translations</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">URIs</span> <span class="p">: </span><span class="nv">URI_Table</span><span class="p">;</span>
<span class="nv">Ranges</span> <span class="p">: </span><span class="nv">Ranges_Table</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- Get_Translations builds the translation table for use with the splitter</span>
<span class="kd">function</span> <span class="nf">Parse</span>
<span class="p">(</span><span class="nv">Template</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">;</span>
<span class="nv">Split_Rule</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Cached</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Parse</span>
<span class="p">(</span><span class="nv">Template</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Table</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Table</span><span class="p">;</span>
<span class="nv">Split_Rule</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Cached</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Parse the Template file and split the result in multiple pages.</span>
<span class="c1">-- Translations is a standard Translate_Set used for all pages. Table</span>
<span class="c1">-- is the Translate_Set containing data for the table to split in</span>
<span class="c1">-- multiple pages. This table will be analysed and according to the</span>
<span class="c1">-- Split_Rule, a set of transient pages will be created.</span>
<span class="c1">-- If Cached is True the template will be cached (see Templates_Parser</span>
<span class="c1">-- documentation).</span>
<span class="c1">-- Each Split_Rule define a number of specific tags for use in the template</span>
<span class="c1">-- file.</span>
<span class="kd">function</span> <span class="nf">Parse</span>
<span class="p">(</span><span class="nv">Template</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Table</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Table</span><span class="p">;</span>
<span class="nv">Max_Per_Page</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">25</span><span class="p">;</span>
<span class="nv">Max_In_Index</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">20</span><span class="p">;</span>
<span class="nv">Cached</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Compatibility function with previous version of AWS.</span>
<span class="c1">-- Uses the Uniform_Splitter</span>
<span class="c1">-- Note that the Max_In_Index parameter is ignored.</span>
<span class="c1">-- The same effect can be achieved by using the bounded_index.thtml</span>
<span class="c1">-- template for displaying the index.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Split_Pages</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-split-pages-alpha">
<span id="id60"></span><h2>13.60. AWS.Services.Split_Pages.Alpha<a class="headerlink" href="#aws-services-split-pages-alpha" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-62"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Split_Pages.Alpha</span> <span class="kr">is</span>
<span class="c1">-- Split in (at most) 28 pages, one for empty fields, one for all fields</span>
<span class="c1">-- that start with a digit, and one for each different initial letter.</span>
<span class="c1">-- Note that leading spaces in the key field are ignored; this means that a</span>
<span class="c1">-- key field containing only spaces is treated as an empty field.</span>
<span class="c1">-- The key field is set by calling Set_Key. If no key is defined, or no</span>
<span class="c1">-- corresponding association is found in Table, or the association is not a</span>
<span class="c1">-- vector, Splitter_Error is raised.</span>
<span class="c1">-- The key field must be sorted, and all values must be empty or start with</span>
<span class="c1">-- a digit or letter (case ignored). Otherwise, Splitter_Error is raised.</span>
<span class="c1">-- Letters that do not appear in the key field are associated to the empty</span>
<span class="c1">-- string; an Href can be specified instead by calling Set_Default_Href.</span>
<span class="c1">--</span>
<span class="c1">-- Tags:</span>
<span class="c1">-- NEXT The href to the next page.</span>
<span class="c1">-- PREVIOUS The href to the previous page.</span>
<span class="c1">-- FIRST The href to the first page.</span>
<span class="c1">-- LAST The href to the last page.</span>
<span class="c1">-- PAGE_INDEX Position of the current page in the INDEXES_V vector</span>
<span class="c1">-- HREFS_V A vector tag containing a set of href to pages, or "" if</span>
<span class="c1">-- their is no page for the corresponding letter.</span>
<span class="c1">-- INDEXES_V A vector tag (synchronized with HREFS_V) containing ' '</span>
<span class="c1">-- and the letters 'A' .. 'Z'</span>
<span class="c1">--</span>
<span class="c1">-- HREFS_V and INDEXES_V can be used to create an index to the generated</span>
<span class="c1">-- pages.</span>
<span class="n">Splitter_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">Split_Pages</span><span class="p">.</span><span class="n">Splitter_Error</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Splitter</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Split_Pages</span><span class="p">.</span><span class="n">Splitter</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Page_Ranges</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ranges_Table</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Translations</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">URIs</span> <span class="p">: </span><span class="nv">URI_Table</span><span class="p">;</span>
<span class="nv">Ranges</span> <span class="p">: </span><span class="nv">Ranges_Table</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Set_Key</span> <span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Splitter</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the key field, this is the name of the vector association in the</span>
<span class="c1">-- translate_set that will be used to create the index.</span>
<span class="kd">procedure</span> <span class="nf">Set_Default_Href</span> <span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Splitter</span><span class="p">;</span> <span class="nv">Href</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Href to use for letter having no entry in the key, if not specified the</span>
<span class="c1">-- empty string is used.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Split_Pages.Alpha</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-split-pages-alpha-bounded">
<span id="id61"></span><h2>13.61. AWS.Services.Split_Pages.Alpha.Bounded<a class="headerlink" href="#aws-services-split-pages-alpha-bounded" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-63"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Split_Pages.Alpha.Bounded</span> <span class="kr">is</span>
<span class="c1">-- Same as the alpha splitter, but pages larger than Max_Per_Page are</span>
<span class="c1">-- further splitted.</span>
<span class="c1">-- A secondary index is generated that gives the various pages for a given</span>
<span class="c1">-- letter.</span>
<span class="c1">--</span>
<span class="c1">-- Tags (in addition to those of the alpha splitter):</span>
<span class="c1">-- S_NEXT The href to the next page.</span>
<span class="c1">-- S_PREVIOUS The href to the previous page.</span>
<span class="c1">-- S_FIRST The href to the first page.</span>
<span class="c1">-- S_LAST The href to the last page.</span>
<span class="c1">-- S_PAGE_INDEX Position of the current page in the S_INDEXES_V vector</span>
<span class="c1">-- Note that for this splitter, this is also the page number.</span>
<span class="c1">-- S_HREFS_V A vector tag containing a set of href to the different</span>
<span class="c1">-- pages for the current letter.</span>
<span class="c1">-- S_INDEXES_V A vector tag (synchronized with S_HREFS_V) containing the</span>
<span class="c1">-- page numbers for the hrefs.</span>
<span class="c1">--</span>
<span class="c1">-- HREFS_V and INDEXES_V can be used to create an index to the generated</span>
<span class="c1">-- pages. S_HREFS_V and S_INDEXES_V can be used to create a secondary</span>
<span class="c1">-- alphabetical index that points directly to the corresponding element.</span>
<span class="kd">type</span> <span class="kt">Splitter</span> <span class="p">(</span><span class="nv">Max_Per_Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Alpha</span><span class="p">.</span><span class="n">Splitter</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Page_Ranges</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ranges_Table</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Translations</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">URIs</span> <span class="p">: </span><span class="nv">URI_Table</span><span class="p">;</span>
<span class="nv">Ranges</span> <span class="p">: </span><span class="nv">Ranges_Table</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span><span class="p">;</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Split_Pages.Alpha.Bounded</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-split-pages-uniform">
<span id="id62"></span><h2>13.62. AWS.Services.Split_Pages.Uniform<a class="headerlink" href="#aws-services-split-pages-uniform" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-64"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Split_Pages.Uniform</span> <span class="kr">is</span>
<span class="c1">-- Split in pages of length Max_Per_Page (except the last one)</span>
<span class="c1">--</span>
<span class="c1">-- Tags:</span>
<span class="c1">-- NEXT The href to the next page.</span>
<span class="c1">-- PREVIOUS The href to the previous page.</span>
<span class="c1">-- FIRST The href to the first page.</span>
<span class="c1">-- LAST The href to the last page.</span>
<span class="c1">-- PAGE_INDEX Position of the current page in the INDEXES_V vector</span>
<span class="c1">-- Note that for this splitter, this is also the page number.</span>
<span class="c1">-- HREFS_V A vector tag containing a set of href to pages.</span>
<span class="c1">-- INDEXES_V A vector tag (synchronized with HREFS_V) containing the</span>
<span class="c1">-- page numbers for the hrefs.</span>
<span class="c1">--</span>
<span class="c1">-- HREFS_V and INDEXES_V can be used to create an index to the generated</span>
<span class="c1">-- pages.</span>
<span class="kd">type</span> <span class="kt">Splitter</span> <span class="p">(</span><span class="nv">Max_Per_Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">is</span>
<span class="kr">new</span> <span class="n">Split_Pages</span><span class="p">.</span><span class="n">Splitter</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Page_Ranges</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ranges_Table</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Translations</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">URIs</span> <span class="p">: </span><span class="nv">URI_Table</span><span class="p">;</span>
<span class="nv">Ranges</span> <span class="p">: </span><span class="nv">Ranges_Table</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span><span class="p">;</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Split_Pages.Uniform</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-split-pages-uniform-alpha">
<span id="id63"></span><h2>13.63. AWS.Services.Split_Pages.Uniform.Alpha<a class="headerlink" href="#aws-services-split-pages-uniform-alpha" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-65"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Split_Pages.Uniform.Alpha</span> <span class="kr">is</span>
<span class="c1">-- Same as the uniform splitter, but builds in addition an alphabetical</span>
<span class="c1">-- secondary index from a key field.</span>
<span class="c1">-- For the references from the index to work, each line of the @@TABLE@@</span>
<span class="c1">-- statement must include the following:</span>
<span class="c1">-- <a name="@_TABLE_LINE_@></span>
<span class="c1">-- The alphabetical index will include one entry for empty fields, one</span>
<span class="c1">-- entry for all fields that start with a digit, and one entry for each</span>
<span class="c1">-- different initial letter.</span>
<span class="c1">-- Note that leading spaces in the key field are ignored; this means that a</span>
<span class="c1">-- key field containing only spaces is treated as an empty field.</span>
<span class="c1">-- The key field is set by calling Set_Key. If no key is defined, or no</span>
<span class="c1">-- corresponding association is found in Table, or the association is not a</span>
<span class="c1">-- vector, Splitter_Error is raised.</span>
<span class="c1">-- The key field must be sorted, and all values must be empty or start with</span>
<span class="c1">-- a digit or letter (case ignored). Otherwise, Splitter_Error is raised.</span>
<span class="c1">--</span>
<span class="c1">-- Tags (in addition to those of the uniform splitter):</span>
<span class="c1">-- S_HREFS_V A vector tag containing a set of href to pages in the form</span>
<span class="c1">-- <page>#<line>.</span>
<span class="c1">-- S_INDEXES_V A vector tag (synchronized with S_HREFS_V) containing</span>
<span class="c1">-- "<>", "0..9", and the letters 'A' .. 'Z'</span>
<span class="c1">--</span>
<span class="c1">-- HREFS_V and INDEXES_V can be used to create an index to the generated</span>
<span class="c1">-- pages. S_HREFS_V and S_INDEXES_V can be used to create a secondary</span>
<span class="c1">-- alphabetical index that points directly to the corresponding element.</span>
<span class="n">Splitter_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">Split_Pages</span><span class="p">.</span><span class="n">Splitter_Error</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Splitter</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Uniform</span><span class="p">.</span><span class="n">Splitter</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Page_Ranges</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ranges_Table</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Translations</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">URIs</span> <span class="p">: </span><span class="nv">URI_Table</span><span class="p">;</span>
<span class="nv">Ranges</span> <span class="p">: </span><span class="nv">Ranges_Table</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Set_Key</span> <span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Splitter</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the key field, this is the name of the vector association in the</span>
<span class="c1">-- translate_set that will be used to create the index.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Split_Pages.Uniform.Alpha</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-split-pages-uniform-overlapping">
<span id="id64"></span><h2>13.64. AWS.Services.Split_Pages.Uniform.Overlapping<a class="headerlink" href="#aws-services-split-pages-uniform-overlapping" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-66"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2004-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Split_Pages.Uniform.Overlapping</span> <span class="kr">is</span>
<span class="c1">-- Same as the uniform splitter, but pages (except the first one)</span>
<span class="c1">-- repeat Overlap lines from the previous page in addition to the</span>
<span class="c1">-- Max_Per_Page lines</span>
<span class="c1">--</span>
<span class="c1">-- Tags:</span>
<span class="c1">-- Same as the Uniform splitter</span>
<span class="kd">type</span> <span class="kt">Splitter</span>
<span class="p">(</span><span class="nv">Max_Per_Page</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">;</span>
<span class="nv">Overlap</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">)</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Uniform</span><span class="p">.</span><span class="n">Splitter</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Get_Page_Ranges</span>
<span class="p">(</span><span class="nv">This</span> <span class="p">: </span><span class="nv">Splitter</span><span class="p">;</span>
<span class="nv">Table</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ranges_Table</span><span class="p">;</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Split_Pages.Uniform.Overlapping</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-transient-pages">
<span id="id65"></span><h2>13.65. AWS.Services.Transient_Pages<a class="headerlink" href="#aws-services-transient-pages" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-67"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Config</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Transient_Pages</span> <span class="kr">is</span>
<span class="kd">function</span> <span class="nf">Get_URI</span> <span class="nf">return</span> <span class="nf">String</span> <span class="nf">with</span>
<span class="nf">Post</span> <span class="p">=></span> <span class="nf">Get_URI</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="nf">0</span><span class="p">;</span>
<span class="c1">-- Create a unique URI, must be used to register a transient web page</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Resource</span> <span class="p">: </span><span class="nv">Resources</span><span class="p">.</span><span class="nv">Streams</span><span class="p">.</span><span class="nv">Stream_Access</span><span class="p">;</span>
<span class="nv">Lifetime</span> <span class="p">: </span><span class="nv">Duration</span> <span class="p">:=</span> <span class="nv">Config</span><span class="p">.</span><span class="nv">Transient_Lifetime</span><span class="p">);</span>
<span class="c1">-- Register a new transient page, this page will be deleted after Lifetime</span>
<span class="c1">-- seconds.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">URI</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Resources</span><span class="p">.</span><span class="n">Streams</span><span class="p">.</span><span class="n">Stream_Access</span><span class="p">;</span>
<span class="c1">-- Returns the stream access for the URI or null if this URI has not been</span>
<span class="c1">-- registered.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Transient_Pages</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-web-block">
<span id="id66"></span><h2>13.66. AWS.Services.Web_Block<a class="headerlink" href="#aws-services-web-block" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-68"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2007-2013, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- Enhanced Contextual Web Framework</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Web_Block</span> <span class="nc">with</span> <span class="nc">Pure</span> <span class="kr">is</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Web_Block</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-web-block-context">
<span id="id67"></span><h2>13.67. AWS.Services.Web_Block.Context<a class="headerlink" href="#aws-services-web-block-context" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-69"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2007-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Containers.Indefinite_Hashed_Maps</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Hash</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">GNAT.SHA1</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Web_Block.Context</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- A context object, can be used to record key/name values</span>
<span class="no">Empty</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Object</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Id</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- An object Id, the Id depends only on the context content. Two context</span>
<span class="c1">-- with the very same content will have the same Id.</span>
<span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">CID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns CID string representation</span>
<span class="kd">function</span> <span class="nf">Value</span> <span class="p">(</span><span class="nv">CID</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Id</span><span class="p">;</span>
<span class="c1">-- Returns Id given it's string representation</span>
<span class="kd">function</span> <span class="nf">Register</span> <span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Id</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Exist</span> <span class="p">(</span><span class="n">Register</span><span class="p">'</span><span class="na">Result</span><span class="p">);</span>
<span class="c1">-- Register the context into the database, returns its Id</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">CID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if CID context exists into the database</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">CID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Returns the context object corresponding to CID</span>
<span class="kd">procedure</span> <span class="nf">Set_Value</span> <span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Name</span><span class="p">,</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Context</span><span class="p">.</span><span class="n">Exist</span> <span class="p">(</span><span class="n">Name</span><span class="p">);</span>
<span class="c1">-- Add a new name/value pair (replace name/value if already present)</span>
<span class="kd">function</span> <span class="nf">Get_Value</span> <span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="p">(</span><span class="kr">if</span> <span class="ow">not</span> <span class="n">Context</span><span class="p">.</span><span class="n">Exist</span> <span class="p">(</span><span class="n">Name</span><span class="p">)</span> <span class="kr">then</span> <span class="n">Get_Value</span><span class="p">'</span><span class="na">Result</span> <span class="o">=</span> <span class="s">""</span><span class="p">);</span>
<span class="c1">-- Returns the value for the key Name or an empty string if does not exist</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns true if the key Name exist in this context</span>
<span class="kd">procedure</span> <span class="nf">Remove</span> <span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Context</span><span class="p">.</span><span class="n">Exist</span> <span class="p">(</span><span class="n">Name</span><span class="p">);</span>
<span class="c1">-- Remove the context for key Name</span>
<span class="kd">generic</span>
<span class="kd">type</span> <span class="kt">Data</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="n">Null_Data</span> <span class="p">:</span> <span class="n">Data</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">Generic_Data</span> <span class="kr">is</span>
<span class="kd">procedure</span> <span class="nf">Set_Value</span>
<span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Value</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Post</span> <span class="p">=></span> <span class="n">Context</span><span class="p">.</span><span class="n">Exist</span> <span class="p">(</span><span class="n">Name</span><span class="p">);</span>
<span class="c1">-- Set key/pair value for the SID</span>
<span class="kd">function</span> <span class="nf">Get_Value</span> <span class="p">(</span><span class="nv">Context</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Data</span>
<span class="kn">with</span>
<span class="nn">Inline</span><span class="p">,</span>
<span class="n">Post</span> <span class="p">=></span> <span class="p">(</span><span class="kr">if</span> <span class="ow">not</span> <span class="n">Context</span><span class="p">.</span><span class="n">Exist</span> <span class="p">(</span><span class="n">Name</span><span class="p">)</span>
<span class="kr">then</span> <span class="n">Get_Value</span><span class="p">'</span><span class="na">Result</span> <span class="o">=</span> <span class="n">Null_Data</span><span class="p">);</span>
<span class="c1">-- Returns the Value for Key in the session SID or Null_Data if</span>
<span class="c1">-- key does not exist.</span>
<span class="kr">end</span> <span class="nf">Generic_Data</span><span class="p">;</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Web_Block.Context</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-services-web-block-registry">
<span id="id68"></span><h2>13.68. AWS.Services.Web_Block.Registry<a class="headerlink" href="#aws-services-web-block-registry" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-70"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2007-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Containers.Tables</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Messages</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.MIME</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Services.Web_Block.Context</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Templates</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Services.Web_Block.Registry</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Page</span> <span class="kr">is</span> <span class="kr">record</span>
<span class="n">Content</span> <span class="p">:</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Rendered page</span>
<span class="n">Content_Type</span> <span class="p">:</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- The page's content type</span>
<span class="n">Set</span> <span class="p">:</span> <span class="n">Templates</span><span class="p">.</span><span class="n">Translate_Set</span><span class="p">;</span>
<span class="c1">-- The translate set used to render the page</span>
<span class="n">Ctx_Id</span> <span class="p">:</span> <span class="n">Context</span><span class="p">.</span><span class="n">Id</span><span class="p">;</span>
<span class="c1">-- The page context id</span>
<span class="kr">end record</span><span class="p">;</span>
<span class="no">No_Page</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Page</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Data_Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Context</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">Web_Block</span><span class="p">.</span><span class="nv">Context</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Callback_Parameters</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Containers</span><span class="p">.</span><span class="n">Tables</span><span class="p">.</span><span class="n">VString_Array</span><span class="p">;</span>
<span class="n">Empty_Callback_Parameters</span> <span class="p">:</span> <span class="n">Callback_Parameters</span> <span class="p">(</span><span class="mi">1</span> <span class="p">..</span> <span class="mi">0</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Data_With_Param_Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Context</span> <span class="p">: </span><span class="nv">not</span> <span class="nv">null</span> <span class="nv">access</span> <span class="nv">Web_Block</span><span class="p">.</span><span class="nv">Context</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Parameters</span> <span class="p">: </span><span class="nv">Callback_Parameters</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">);</span>
<span class="kd">type</span> <span class="kt">Template_Callback</span> <span class="kr">is</span> <span class="kr">access</span>
<span class="kd">function</span> <span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Template</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data_CB</span> <span class="p">: </span><span class="nv">Data_Callback</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_HTML</span><span class="p">;</span>
<span class="nv">Prefix</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Context_Required</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Key is a Lazy_Tag or template page name. Template is the corresponding</span>
<span class="c1">-- template file. Data_CB is the callback used to retrieve the translation</span>
<span class="c1">-- table to render the page. If Context_Required is True a proper context</span>
<span class="c1">-- must be present when rendering the page otherwise Context_Error callback</span>
<span class="c1">-- (see Build below) is called.</span>
<span class="kd">procedure</span> <span class="nf">Register</span>
<span class="p">(</span><span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Template_CB</span> <span class="p">: </span><span class="nv">Template_Callback</span><span class="p">;</span>
<span class="nv">Data_CB</span> <span class="p">: </span><span class="nv">Data_Callback</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_HTML</span><span class="p">;</span>
<span class="nv">Context_Required</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Key is a Lazy_Tag or template page name. Template_CB is the callback</span>
<span class="c1">-- used to retrieve the corresponding template file name. Data_CB is the</span>
<span class="c1">-- callback used to retrieve the translation table to render the page.</span>
<span class="kd">procedure</span> <span class="nf">Register_Pattern_URL</span>
<span class="p">(</span><span class="nv">Prefix</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Regexp</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Template</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Data_CB</span> <span class="p">: </span><span class="nv">Data_With_Param_Callback</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_HTML</span><span class="p">;</span>
<span class="nv">Context_Required</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Prefix is the prefix key to match</span>
<span class="c1">-- Then the rest of the url is a regular expression defined by Regexp</span>
<span class="c1">-- All regular-expression groups (inside parenthesis) is captured and pass</span>
<span class="c1">-- to the Data_CB in the Parameters vector</span>
<span class="c1">-- For instance, with:</span>
<span class="c1">-- Prefix = '/page/'</span>
<span class="c1">-- Regexp = '([0-9]+)/section-([a-z]+)/.*'</span>
<span class="c1">-- The url '/page/42/section-b/part2' will be matched and Data_CB will</span>
<span class="c1">-- be called with Parameters = <42, "b"></span>
<span class="kd">procedure</span> <span class="nf">Register_Pattern_URL</span>
<span class="p">(</span><span class="nv">Prefix</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Regexp</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Template_CB</span> <span class="p">: </span><span class="nv">Template_Callback</span><span class="p">;</span>
<span class="nv">Data_CB</span> <span class="p">: </span><span class="nv">Data_With_Param_Callback</span><span class="p">;</span>
<span class="nv">Content_Type</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">.</span><span class="nv">Text_HTML</span><span class="p">;</span>
<span class="nv">Context_Required</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">);</span>
<span class="c1">-- Same as above but takes a Template_Callback</span>
<span class="kd">function</span> <span class="nf">Parse</span>
<span class="p">(</span><span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">;</span>
<span class="nv">Context</span> <span class="p">: </span><span class="nv">Web_Block</span><span class="p">.</span><span class="nv">Context</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Web_Block</span><span class="p">.</span><span class="nv">Context</span><span class="p">.</span><span class="nv">Empty</span><span class="p">;</span>
<span class="nv">Context_Error</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Page</span><span class="p">;</span>
<span class="c1">-- Parse the Web page registered under Key. Context_Error is the key</span>
<span class="c1">-- of the registered template to use when a required context is not</span>
<span class="c1">-- present.</span>
<span class="kd">function</span> <span class="nf">Content_Type</span> <span class="p">(</span><span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the Content_Type recorded for the web object</span>
<span class="kd">function</span> <span class="nf">Build</span>
<span class="p">(</span><span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Translations</span> <span class="p">: </span><span class="nv">Templates</span><span class="p">.</span><span class="nv">Translate_Set</span><span class="p">;</span>
<span class="nv">Status_Code</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Status_Code</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">S200</span><span class="p">;</span>
<span class="nv">Cache_Control</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Cache_Option</span> <span class="p">:=</span> <span class="nv">Messages</span><span class="p">.</span><span class="nv">Unspecified</span><span class="p">;</span>
<span class="nv">Context</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">Web_Block</span><span class="p">.</span><span class="nv">Context</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">null</span><span class="p">;</span>
<span class="nv">Context_Error</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- Same as above but returns a standard Web page. If Context is set it</span>
<span class="c1">-- is the initial value and will be setup at the end to correspond to</span>
<span class="c1">-- the recorded new context.</span>
<span class="kd">function</span> <span class="nf">Get_Context</span>
<span class="p">(</span><span class="nv">Request</span> <span class="p">: </span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Web_Block</span><span class="p">.</span><span class="n">Context</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Gets the proper context object for this request. Note that if the</span>
<span class="c1">-- context object is modified outside of the Web_Block framework it must be</span>
<span class="c1">-- passed to the Build or Parse procedure above.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Services.Web_Block.Registry</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-session">
<span id="id69"></span><h2>13.69. AWS.Session<a class="headerlink" href="#aws-session" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-71"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This is the API to handle session data for each client connected</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Config</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Session</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Id</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Value_Kind</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Int</span><span class="p">,</span> <span class="nv">Str</span><span class="p">,</span> <span class="nv">Real</span><span class="p">,</span> <span class="nv">Bool</span><span class="p">,</span> <span class="nv">User</span><span class="p">);</span>
<span class="no">No_Session</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Id</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Create</span> <span class="nf">return</span> <span class="nf">Id</span> <span class="nf">with</span>
<span class="nf">Post</span> <span class="p">=></span> <span class="nf">Create</span><span class="p">'</span><span class="na">Result</span> <span class="o">/=</span> <span class="nf">No_Session</span><span class="p">;</span>
<span class="c1">-- Create a new uniq Session Id</span>
<span class="kd">procedure</span> <span class="nf">Delete</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">);</span>
<span class="c1">-- Delete session, does nothing if SID does not exist.</span>
<span class="c1">-- In most cases, the client browser will still send the cookie identifying</span>
<span class="c1">-- the session on its next request. In such a case, the function</span>
<span class="c1">-- AWS.Status.Timed_Out will return True, same as when the session was</span>
<span class="c1">-- deleted automatically by AWS when it expired.</span>
<span class="c1">-- The recommended practice is therefore to call</span>
<span class="c1">-- AWS.Response.Set.Clear_Session when you send a response to the customer</span>
<span class="c1">-- after deleting the session, so that the cookie is not sent again.</span>
<span class="kd">function</span> <span class="nf">Delete_If_Empty</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Delete session only if there is no key/value pairs.</span>
<span class="c1">-- Returns True if session deleted.</span>
<span class="c1">-- Need to delete not used just created session to avoid too many empty</span>
<span class="c1">-- session creation.</span>
<span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Return ID image</span>
<span class="kd">function</span> <span class="nf">Value</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Id</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Build an ID from a String, returns No_Session if SID is not recongnized</span>
<span class="c1">-- as an AWS session ID.</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if SID exist</span>
<span class="kd">procedure</span> <span class="nf">Touch</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">);</span>
<span class="c1">-- Update to current time the timestamp associated with SID. Does nothing</span>
<span class="c1">-- if SID does not exist.</span>
<span class="kd">procedure</span> <span class="nf">Set</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set key/value pair for the SID</span>
<span class="kd">procedure</span> <span class="nf">Set</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Integer</span><span class="p">);</span>
<span class="c1">-- Set key/value pair for the SID</span>
<span class="kd">procedure</span> <span class="nf">Set</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Float</span><span class="p">);</span>
<span class="c1">-- Set key/value pair for the SID</span>
<span class="kd">procedure</span> <span class="nf">Set</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">);</span>
<span class="c1">-- Set key/value pair for the SID</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span>
<span class="nn">Inline</span> <span class="p">=></span> <span class="kc">True</span><span class="p">,</span>
<span class="n">Post</span> <span class="p">=></span> <span class="p">(</span><span class="ow">not</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">)</span> <span class="ow">and then</span> <span class="n">Get</span><span class="p">'</span><span class="na">Result</span><span class="p">'</span><span class="na">Length</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
<span class="ow">or else</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">);</span>
<span class="c1">-- Returns the Value for Key in the session SID or the emptry string if</span>
<span class="c1">-- key does not exist.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span> <span class="kn">with</span>
<span class="nn">Inline</span> <span class="p">=></span> <span class="kc">True</span><span class="p">,</span>
<span class="n">Post</span> <span class="p">=></span> <span class="p">(</span><span class="ow">not</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">)</span> <span class="ow">and then</span> <span class="n">Get</span><span class="p">'</span><span class="na">Result</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
<span class="ow">or else</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">);</span>
<span class="c1">-- Returns the Value for Key in the session SID or the integer value 0 if</span>
<span class="c1">-- key does not exist or is not an integer.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Float</span> <span class="kn">with</span>
<span class="nn">Inline</span> <span class="p">=></span> <span class="kc">True</span><span class="p">,</span>
<span class="n">Post</span> <span class="p">=></span> <span class="p">(</span><span class="ow">not</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">)</span> <span class="ow">and then</span> <span class="n">Get</span><span class="p">'</span><span class="na">Result</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">)</span>
<span class="ow">or else</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">);</span>
<span class="c1">-- Returns the Value for Key in the session SID or the float value 0.0 if</span>
<span class="c1">-- key does not exist or is not a float.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span>
<span class="nn">Inline</span> <span class="p">=></span> <span class="kc">True</span><span class="p">,</span>
<span class="n">Post</span> <span class="p">=></span> <span class="p">(</span><span class="ow">not</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">)</span> <span class="ow">and then</span> <span class="n">Get</span><span class="p">'</span><span class="na">Result</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span>
<span class="ow">or else</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">);</span>
<span class="c1">-- Returns the Value for Key in the session SID or the boolean False if</span>
<span class="c1">-- key does not exist or is not a boolean.</span>
<span class="kd">generic</span>
<span class="kd">type</span> <span class="kt">Data</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="n">Null_Data</span> <span class="p">:</span> <span class="n">Data</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">Generic_Data</span> <span class="kr">is</span>
<span class="kd">procedure</span> <span class="nf">Set</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Value</span> <span class="p">: </span><span class="nv">Data</span><span class="p">);</span>
<span class="c1">-- Set key/value pair for the SID</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Data</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the Value for Key in the session SID or Null_Data if</span>
<span class="c1">-- key does not exist.</span>
<span class="kr">end</span> <span class="nf">Generic_Data</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Remove</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="ow">not</span> <span class="n">Exist</span> <span class="p">(</span><span class="n">SID</span><span class="p">,</span> <span class="n">Key</span><span class="p">);</span>
<span class="c1">-- Removes Key from the specified session</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">;</span> <span class="nv">Key</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if Key exist in session SID</span>
<span class="kd">function</span> <span class="nf">Server_Count</span> <span class="nf">return</span> <span class="nf">Natural</span><span class="p">;</span>
<span class="c1">-- Returns number of servers with sessions support</span>
<span class="kd">function</span> <span class="nf">Length</span> <span class="nf">return</span> <span class="nf">Natural</span><span class="p">;</span>
<span class="c1">-- Returns number of sessions</span>
<span class="kd">function</span> <span class="nf">Length</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns number of key/value pairs in session SID</span>
<span class="kd">procedure</span> <span class="nf">Clear</span> <span class="nf">with</span> <span class="nf">Post</span> <span class="p">=></span> <span class="nf">Length</span> <span class="o">=</span> <span class="nf">0</span><span class="p">;</span>
<span class="c1">-- Removes all sessions data</span>
<span class="c1">---------------</span>
<span class="c1">-- Iterators --</span>
<span class="c1">---------------</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">N</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">SID</span> <span class="p">:</span> <span class="n">Id</span><span class="p">;</span>
<span class="n">Time_Stamp</span> <span class="p">:</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Session</span><span class="p">;</span>
<span class="c1">-- Iterator which call Action for every active session. N is the SID</span>
<span class="c1">-- order. Time_Stamp is the time when SID was updated for the last</span>
<span class="c1">-- time. Quit is set to False by default, it is possible to control the</span>
<span class="c1">-- iterator termination by setting its value to True. Note that in the</span>
<span class="c1">-- Action procedure it is possible to use routines that read session's</span>
<span class="c1">-- data (Get, Exist) but any routines which modify the data will block</span>
<span class="c1">-- (i.e. Touch, Set, Remove, Delete will dead lock).</span>
<span class="kd">generic</span>
<span class="kn">with</span> <span class="nn">procedure</span> <span class="n">Action</span>
<span class="p">(</span><span class="n">N</span> <span class="p">:</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="n">Key</span><span class="p">,</span> <span class="n">Value</span> <span class="p">:</span> <span class="kt">String</span><span class="p">;</span>
<span class="n">Kind</span> <span class="p">:</span> <span class="n">Value_Kind</span><span class="p">;</span>
<span class="n">Quit</span> <span class="p">:</span> <span class="ow">in</span> <span class="kr">out</span> <span class="kt">Boolean</span><span class="p">);</span>
<span class="kd">procedure</span> <span class="nf">For_Every_Session_Data</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">);</span>
<span class="c1">-- Iterator which returns all the key/value pair defined for session SID.</span>
<span class="c1">-- Quit is set to False by default, it is possible to control the iterator</span>
<span class="c1">-- termination by setting its value to True. Note that in the Action</span>
<span class="c1">-- procedure it is possible to use routines that read session's data (Get,</span>
<span class="c1">-- Exist) but any routines which modify the data will block (i.e. Touch,</span>
<span class="c1">-- Set, Remove, Delete will dead lock).</span>
<span class="c1">--------------</span>
<span class="c1">-- Lifetime --</span>
<span class="c1">--------------</span>
<span class="kd">procedure</span> <span class="nf">Set_Lifetime</span> <span class="p">(</span><span class="nv">Seconds</span> <span class="p">: </span><span class="nv">Duration</span><span class="p">);</span>
<span class="c1">-- Set the lifetime for session data. At the point a session is deleted,</span>
<span class="c1">-- reusing the session ID makes AWS.Status.Session_Timed_Out return True.</span>
<span class="kd">function</span> <span class="nf">Get_Lifetime</span> <span class="nf">return</span> <span class="nf">Duration</span><span class="p">;</span>
<span class="c1">-- Get current session lifetime for session data</span>
<span class="kd">function</span> <span class="nf">Has_Expired</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns true if SID should be considered as expired (ie there hasn't</span>
<span class="c1">-- been any transaction on it since Get_Lifetime seconds. Such a session</span>
<span class="c1">-- should be deleted. Calling this function is mostly internal to AWS, and</span>
<span class="c1">-- sessions are deleted automatically when they expire.</span>
<span class="c1">----------------------</span>
<span class="c1">-- Session Callback --</span>
<span class="c1">----------------------</span>
<span class="kd">type</span> <span class="kt">Callback</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kd">procedure</span> <span class="p">(</span><span class="nv">SID</span> <span class="p">: </span><span class="nv">Id</span><span class="p">);</span>
<span class="c1">-- Callback procedure called when a sesssion is deleted from the server</span>
<span class="kd">procedure</span> <span class="nf">Set_Callback</span> <span class="p">(</span><span class="nv">Callback</span> <span class="p">: </span><span class="nv">Session</span><span class="p">.</span><span class="nv">Callback</span><span class="p">);</span>
<span class="c1">-- Set the callback procedure to call when a session is deleted from the</span>
<span class="c1">-- server. If Callback is Null the session's callback will be removed.</span>
<span class="c1">----------------</span>
<span class="c1">-- Session IO --</span>
<span class="c1">----------------</span>
<span class="kd">procedure</span> <span class="nf">Save</span> <span class="p">(</span><span class="nv">File_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Save all sessions data into File_Name</span>
<span class="kd">procedure</span> <span class="nf">Load</span> <span class="p">(</span><span class="nv">File_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Restore all sessions data from File_Name</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Session</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-smtp">
<span id="id70"></span><h2>13.70. AWS.SMTP<a class="headerlink" href="#aws-smtp" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-72"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This library implement the Simple Mail Transfer Protocol. Only part of the</span>
<span class="c1">-- RFC 821 is covered. There is no support to send a message to a console for</span>
<span class="c1">-- example.</span>
<span class="kn">with</span> <span class="nn">AWS.Net</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kr">limited</span> <span class="kn">with</span> <span class="nn">AWS.SMTP.Authentication</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.SMTP</span> <span class="kr">is</span>
<span class="n">Server_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when an unrecoverable error is found</span>
<span class="n">Reply_Code_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when a reply code error is not known</span>
<span class="no">Default_SMTP_Port</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">25</span><span class="p">;</span>
<span class="c1">--------------</span>
<span class="c1">-- Receiver --</span>
<span class="c1">--------------</span>
<span class="kd">type</span> <span class="kt">Receiver</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- The receiver part (i.e. a server) of SMTP messages as defined in</span>
<span class="c1">-- RFC 821. This is the SMTP server.</span>
<span class="kd">function</span> <span class="nf">Initialize</span>
<span class="p">(</span><span class="nv">Server_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Default_SMTP_Port</span><span class="p">;</span>
<span class="nv">Secure</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Family</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Family_Type</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Family_Unspec</span><span class="p">;</span>
<span class="nv">Credential</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">constant</span> <span class="nv">Authentication</span><span class="p">.</span><span class="nv">Credential</span><span class="p">'</span><span class="na">Class</span> <span class="p">:=</span> <span class="nv">null</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Receiver</span><span class="p">;</span>
<span class="c1">-- Create a Server composed of the Name and the Port (default SMTP port</span>
<span class="c1">-- is 25), this server will be used to send SMTP message.</span>
<span class="c1">----------------</span>
<span class="c1">-- Reply_Code --</span>
<span class="c1">----------------</span>
<span class="kd">type</span> <span class="kt">Reply_Code</span> <span class="kr">is</span> <span class="kr">range</span> <span class="mi">200</span> <span class="p">..</span> <span class="mi">554</span><span class="p">;</span>
<span class="no">Service_Ready</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">220</span><span class="p">;</span>
<span class="no">Service_Closing</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">221</span><span class="p">;</span>
<span class="no">Auth_Successful</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">235</span><span class="p">;</span>
<span class="no">Requested_Action_Ok</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">250</span><span class="p">;</span>
<span class="no">Provide_Watchword</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">334</span><span class="p">;</span>
<span class="no">Start_Mail_Input</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">354</span><span class="p">;</span>
<span class="no">Syntax_Error</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Reply_Code</span> <span class="p">:=</span> <span class="mi">500</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">R</span> <span class="p">: </span><span class="nv">Reply_Code</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the reply code as a string. Raises Reply_Code_Error if R is</span>
<span class="c1">-- not a valid reply code.</span>
<span class="kd">function</span> <span class="nf">Name</span> <span class="p">(</span><span class="nv">R</span> <span class="p">: </span><span class="nv">Reply_Code</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the reply code reason string. Raises Reply_Code_Error if R is</span>
<span class="c1">-- not a valid reply code.</span>
<span class="kd">function</span> <span class="nf">Message</span> <span class="p">(</span><span class="nv">R</span> <span class="p">: </span><span class="nv">Reply_Code</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- This returns the value: Image (R) & ' ' & Name (R)</span>
<span class="c1">------------</span>
<span class="c1">-- Status --</span>
<span class="c1">------------</span>
<span class="kd">type</span> <span class="kt">Status</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Is_Ok</span> <span class="p">(</span><span class="nv">Status</span> <span class="p">: </span><span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Return True is status if Ok (no problem) or false if a problem has been</span>
<span class="c1">-- detected. This is not an error (in that case Error is raised) but a</span>
<span class="c1">-- warning because something wrong (but not unrecoverable) has happen.</span>
<span class="kd">function</span> <span class="nf">Status_Message</span> <span class="p">(</span><span class="nv">Status</span> <span class="p">: </span><span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- If Is_Ok is False, this function return the reason of the problem. The</span>
<span class="c1">-- return message is the error message as reported by the server.</span>
<span class="kd">function</span> <span class="nf">Status_Code</span> <span class="p">(</span><span class="nv">Status</span> <span class="p">: </span><span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Reply_Code</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the code replied by the server</span>
<span class="kd">procedure</span> <span class="nf">Clear</span> <span class="p">(</span><span class="nv">Status</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Clear Status value. Code is set to Requested_Action_Ok and message</span>
<span class="c1">-- string to null.</span>
<span class="c1">-----------------</span>
<span class="c1">-- E_Mail_Data --</span>
<span class="c1">-----------------</span>
<span class="kd">type</span> <span class="kt">E_Mail_Data</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Address_Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">Full</span><span class="p">,</span> <span class="nv">Name</span><span class="p">,</span> <span class="nv">Address</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Image</span>
<span class="p">(</span><span class="nv">E_Mail</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Address_Mode</span> <span class="p">:=</span> <span class="nv">Full</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns E_Mail only (Mode = Address), recipient name only (Mode = Name)</span>
<span class="c1">-- or Name and e-mail (Mode = Full).</span>
<span class="kd">function</span> <span class="nf">E_Mail</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Address</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">E_Mail_Data</span><span class="p">;</span>
<span class="c1">-- Returns an e-mail address</span>
<span class="kd">function</span> <span class="nf">Parse</span> <span class="p">(</span><span class="nv">E_Mail</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">E_Mail_Data</span><span class="p">;</span>
<span class="c1">-- Parse an e-mail with format "Name <address>" or "address (Name)"</span>
<span class="c1">-- and Returns the corresponding E_Mail_Data. Raises Contraint_Error</span>
<span class="c1">-- if E_Mail can't be parsed.</span>
<span class="kd">type</span> <span class="kt">Recipients</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">E_Mail_Data</span><span class="p">;</span>
<span class="no">No_Recipient</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Recipients</span> <span class="p">(</span><span class="mi">1</span> <span class="p">..</span> <span class="mi">0</span><span class="p">);</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.SMTP</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-smtp-client">
<span id="id71"></span><h2>13.71. AWS.SMTP.Client<a class="headerlink" href="#aws-smtp-client" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-73"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2017, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">--</span>
<span class="c1">-- This unit implements an API to send email messages. It is possible to send</span>
<span class="c1">-- simple email [RFC 821] and email with MIME attachments [RFC 2045 & 2049].</span>
<span class="c1">--</span>
<span class="c1">-- How to send an email:</span>
<span class="c1">--</span>
<span class="c1">-- 1) Initialize a Server to send the messages.</span>
<span class="c1">--</span>
<span class="c1">-- Wanadoo : SMTP.Receiver := SMTP.Client.Initialize ("smtp.wanadoo.fr");</span>
<span class="c1">--</span>
<span class="c1">-- Optionally, request Authentication</span>
<span class="c1">--</span>
<span class="c1">-- Auth : aliased SMTP.Authentication.Credential :=</span>
<span class="c1">-- SMTP.Authentication.Plain.Initialize ("id", "password");</span>
<span class="c1">--</span>
<span class="c1">-- Wanadoo : SMTP.Receiver :=</span>
<span class="c1">-- SMTP.Client.Initialize</span>
<span class="c1">-- ("smtp.wanadoo.fr", Credential => Auth'Access);</span>
<span class="c1">--</span>
<span class="c1">-- 2) Send a message via the server.</span>
<span class="c1">--</span>
<span class="c1">-- Result : SMTP.Status;</span>
<span class="c1">--</span>
<span class="c1">-- SMTP.Client.Send</span>
<span class="c1">-- (Server => Wanadoo,</span>
<span class="c1">-- From => SMTP.E_Mail ("Pascal Obry", "pascal@obry.net"),</span>
<span class="c1">-- To => SMTP.E_Mail</span>
<span class="c1">-- ("Dmitriy Anisimkov", "anisimkov@ada-ru.org"),</span>
<span class="c1">-- Subject => "Latest Ada news",</span>
<span class="c1">-- Message => "now Ada can send SMTP mail!",</span>
<span class="c1">-- Status => Result);</span>
<span class="kn">with</span> <span class="nn">AWS.Attachments</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.SMTP.Client</span> <span class="kr">is</span>
<span class="n">Server_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">SMTP</span><span class="p">.</span><span class="n">Server_Error</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Initialize</span>
<span class="p">(</span><span class="nv">Server_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Port</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">Default_SMTP_Port</span><span class="p">;</span>
<span class="nv">Secure</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Family</span> <span class="p">: </span><span class="nv">Net</span><span class="p">.</span><span class="nv">Family_Type</span> <span class="p">:=</span> <span class="nv">Net</span><span class="p">.</span><span class="nv">Family_Unspec</span><span class="p">;</span>
<span class="nv">Credential</span> <span class="p">: </span><span class="nv">access</span> <span class="nv">constant</span> <span class="nv">Authentication</span><span class="p">.</span><span class="nv">Credential</span><span class="p">'</span><span class="na">Class</span> <span class="p">:=</span> <span class="nv">null</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Receiver</span> <span class="kr">renames</span> <span class="n">SMTP</span><span class="p">.</span><span class="n">Initialize</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">Subject</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- Send a message via Server. The email is a simple message composed of a</span>
<span class="c1">-- subject and a text message body. Raise Server_Error in case of an</span>
<span class="c1">-- unrecoverable error (e.g. can't contact the server).</span>
<span class="kd">type</span> <span class="kt">Attachment</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- This is an attachment object, either a File or some Base64 encoded</span>
<span class="c1">-- content.</span>
<span class="c1">-- only simple attachments are supported. For full attachment support use</span>
<span class="c1">-- AWS.Attachments with the corresponding Send routine below.</span>
<span class="kd">function</span> <span class="nf">File</span> <span class="p">(</span><span class="nv">Filename</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Attachment</span><span class="p">;</span>
<span class="c1">-- Returns a file attachment. Filename point to a file on the file system</span>
<span class="kd">function</span> <span class="nf">Base64_Data</span> <span class="p">(</span><span class="nv">Name</span><span class="p">,</span> <span class="nv">Content</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Attachment</span><span class="p">;</span>
<span class="c1">-- Returns a base64 encoded attachment. Content must already be Base64</span>
<span class="c1">-- encoded data. The attachment is named Name.</span>
<span class="c1">-- This is a way to send a file attachment from in-memory data.</span>
<span class="kd">type</span> <span class="kt">Attachment_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Attachment</span><span class="p">;</span>
<span class="c1">-- A set of file attachments</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">Subject</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_Set</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- Send a message via Server. The email is a MIME message composed of a</span>
<span class="c1">-- subject, a message and a set of MIME encoded files. Raise Server_Error</span>
<span class="c1">-- in case of an unrecoverable error (e.g. can't contact the server).</span>
<span class="c1">-- Raises Constraint_Error if a file attachment cannot be opened.</span>
<span class="kd">type</span> <span class="kt">Message_File</span> <span class="kr">is</span> <span class="kr">new</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">Subject</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Filename</span> <span class="p">: </span><span class="nv">Message_File</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- Send filename content via Server. The email is a message composed of a</span>
<span class="c1">-- subject and a message body coming from a file. Raises Server_Error in</span>
<span class="c1">-- case of an unrecoverable error (e.g. can't contact the server). Raises</span>
<span class="c1">-- Constraint_Error if Filename cannot be opened.</span>
<span class="c1">--</span>
<span class="c1">-- Extentded interfaces to send a message to many recipients</span>
<span class="c1">--</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Recipients</span><span class="p">;</span>
<span class="nv">Subject</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- Send a message via Server. The mail is a simple message composed of a</span>
<span class="c1">-- subject and a text message body. Raise Server_Error in case of an</span>
<span class="c1">-- unrecoverable error (e.g. can't contact the server).</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Recipients</span><span class="p">;</span>
<span class="nv">Source</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- Send a message via Server. The email Source has already been composed by</span>
<span class="c1">-- other means, such as the GNATcoll email facilities.</span>
<span class="c1">-- Raise Server_Error in case of an unrecoverable error, e.g. can't contact</span>
<span class="c1">-- the server.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Recipients</span><span class="p">;</span>
<span class="nv">Subject</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Message</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">Attachment_Set</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- Send a message via Server. The email is a MIME message composed of a</span>
<span class="c1">-- subject, a message and a set of files MIME encoded. Raise Server_Error</span>
<span class="c1">-- in case of an unrecoverable error (e.g. can't contact the server).</span>
<span class="c1">-- Raises Constraint_Error if a file attachment cannot be opened.</span>
<span class="kd">procedure</span> <span class="nf">Send</span>
<span class="p">(</span><span class="nv">Server</span> <span class="p">: </span><span class="nv">Receiver</span><span class="p">;</span>
<span class="nv">From</span> <span class="p">: </span><span class="nv">E_Mail_Data</span><span class="p">;</span>
<span class="nv">To</span> <span class="p">: </span><span class="nv">Recipients</span><span class="p">;</span>
<span class="nv">Subject</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Attachments</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Attachments</span><span class="p">.</span><span class="nv">List</span><span class="p">;</span>
<span class="nv">Status</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">SMTP</span><span class="p">.</span><span class="nv">Status</span><span class="p">;</span>
<span class="nv">CC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">;</span>
<span class="nv">BCC</span> <span class="p">: </span><span class="nv">Recipients</span> <span class="p">:=</span> <span class="nv">No_Recipient</span><span class="p">);</span>
<span class="c1">-- As above but takes an attachment list which support complex attachments</span>
<span class="c1">-- like multiplart/alternative.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.SMTP.Client</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-status">
<span id="id72"></span><h2>13.72. AWS.Status<a class="headerlink" href="#aws-status" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-74"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package is used to keep the HTTP protocol status. Client can then</span>
<span class="c1">-- request the status for various values like the requested URI, the</span>
<span class="c1">-- Content_Length and the Session ID for example.</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Real_Time</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Attachments</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Headers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Messages</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Net</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Parameters</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Session</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.URL</span><span class="p">;</span>
<span class="kd">private</span> <span class="kn">with</span> <span class="nn">AWS.Resources.Streams.Memory</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Status</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Data</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Request_Method</span> <span class="kr">is</span>
<span class="p">(</span><span class="nv">OPTIONS</span><span class="p">,</span> <span class="nv">GET</span><span class="p">,</span> <span class="nv">HEAD</span><span class="p">,</span> <span class="nv">POST</span><span class="p">,</span> <span class="nv">PUT</span><span class="p">,</span> <span class="nv">DELETE</span><span class="p">,</span> <span class="nv">TRACE</span><span class="p">,</span> <span class="nv">CONNECT</span><span class="p">,</span> <span class="nv">EXTENSION_METHOD</span><span class="p">);</span>
<span class="c1">-- EXTENSION_METHOD indicates that a method is an extension-method,</span>
<span class="c1">-- ie none of the eight method tokens predefined in the RFC 2616.</span>
<span class="kd">type</span> <span class="kt">Authorization_Type</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">None</span><span class="p">,</span> <span class="nv">Basic</span><span class="p">,</span> <span class="nv">Digest</span><span class="p">);</span>
<span class="c1">------------------</span>
<span class="c1">-- Request-Line --</span>
<span class="c1">------------------</span>
<span class="kd">function</span> <span class="nf">Method</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Request_Method</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the request method</span>
<span class="kd">function</span> <span class="nf">Method</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the request method as a String. Useful to get the method String</span>
<span class="c1">-- for an extension-method, ie a method that is not already predefined</span>
<span class="c1">-- in the RFC 2616.</span>
<span class="kd">function</span> <span class="nf">URI</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the requested resource</span>
<span class="kd">function</span> <span class="nf">URI</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">URL</span><span class="p">.</span><span class="n">Object</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- As above but return an URL object</span>
<span class="kd">function</span> <span class="nf">URL</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the requested URL</span>
<span class="kd">function</span> <span class="nf">Parameters</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Parameters</span><span class="p">.</span><span class="n">List</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the list of parameters for the request. This list can be empty</span>
<span class="c1">-- if there was no form or URL parameters.</span>
<span class="kd">function</span> <span class="nf">Parameter</span>
<span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">HTTP_Version</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the HTTP version used by the client</span>
<span class="kd">function</span> <span class="nf">Request_Time</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the time of the request</span>
<span class="kd">function</span> <span class="nf">Request_Time</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Real_Time</span><span class="p">.</span><span class="n">Time</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">------------</span>
<span class="c1">-- Header --</span>
<span class="c1">------------</span>
<span class="kd">function</span> <span class="nf">Header</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Headers</span><span class="p">.</span><span class="n">List</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the list of header lines for the request</span>
<span class="kd">function</span> <span class="nf">Accept_Encoding</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get the value for "Accept-Encoding:" header</span>
<span class="kd">function</span> <span class="nf">Connection</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get the value for "Connection:" header</span>
<span class="kd">function</span> <span class="nf">Content_Length</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get the value for "Content-Length:" header, this is the number of</span>
<span class="c1">-- bytes in the message body.</span>
<span class="kd">function</span> <span class="nf">Content_Type</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Content-Type:" header</span>
<span class="kd">function</span> <span class="nf">Transfer_Encoding</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Transfer-Encoding:" header</span>
<span class="kd">function</span> <span class="nf">Expect</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Expect:" header</span>
<span class="kd">function</span> <span class="nf">Host</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Host:" header</span>
<span class="kd">function</span> <span class="nf">If_Modified_Since</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "If-Modified-Since:" header</span>
<span class="kd">function</span> <span class="nf">Keep_Alive</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the flag if the current HTTP connection is keep-alive</span>
<span class="kd">function</span> <span class="nf">User_Agent</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "User-Agent:" header</span>
<span class="kd">function</span> <span class="nf">Referer</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Referer:" header</span>
<span class="kd">function</span> <span class="nf">Cache_Control</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Cache_Option</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Cache-Control:" header</span>
<span class="kd">function</span> <span class="nf">Cache_Control</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Cache_Data</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the cache control data specified for the request</span>
<span class="kd">function</span> <span class="nf">Is_Supported</span>
<span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Messages</span><span class="p">.</span><span class="nv">Content_Encoding</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the content encoding scheme is supported by the client</span>
<span class="kd">function</span> <span class="nf">Preferred_Coding</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Content_Encoding</span><span class="p">;</span>
<span class="c1">-- Returns supported by AWS coding preferred by client from the</span>
<span class="c1">-- Accept-Coding header.</span>
<span class="kd">function</span> <span class="nf">Upgrade</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Upgrade:" header</span>
<span class="kd">function</span> <span class="nf">Sec_WebSocket_Key</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Sec-WebSocket-Key:" header</span>
<span class="c1">-------------------------------------------</span>
<span class="c1">-- Cross-Origin Resource Sharing Headers --</span>
<span class="c1">-------------------------------------------</span>
<span class="kd">function</span> <span class="nf">Origin</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Origin:" header</span>
<span class="kd">function</span> <span class="nf">Access_Control_Request_Headers</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Access-Control-Request-Headers:" header</span>
<span class="kd">function</span> <span class="nf">Access_Control_Request_Method</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "Access-Control-Request-Method:" header</span>
<span class="c1">----------------</span>
<span class="c1">-- Connection --</span>
<span class="c1">----------------</span>
<span class="kd">function</span> <span class="nf">Peername</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the address of the peer (the IP address of the client computer)</span>
<span class="kd">function</span> <span class="nf">Socket</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Net</span><span class="p">.</span><span class="n">Socket_Type</span><span class="p">'</span><span class="na">Class</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the socket used to transfer data between the client and</span>
<span class="c1">-- server.</span>
<span class="kd">function</span> <span class="nf">Socket</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Net</span><span class="p">.</span><span class="n">Socket_Access</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the socket used to transfer data between the client and</span>
<span class="c1">-- server. Use Socket_Access to avoid memory allocation if we would need</span>
<span class="c1">-- socket access further.</span>
<span class="c1">----------</span>
<span class="c1">-- Data --</span>
<span class="c1">----------</span>
<span class="kd">function</span> <span class="nf">Is_Body_Uploaded</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if the message body has been uploaded and False if not.</span>
<span class="c1">-- The reason being that the body size is above Upload_Size_Limit.</span>
<span class="c1">-- User can upload the file using AWS.Server.Get_Message_Body, the size</span>
<span class="c1">-- being returned by Content_Length.</span>
<span class="kd">function</span> <span class="nf">Multipart_Boundary</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for the boundary part in "Content-Type: ...; boundary=..."</span>
<span class="c1">-- parameter. This is a string that will be used to separate each chunk of</span>
<span class="c1">-- data in a multipart message.</span>
<span class="kd">function</span> <span class="nf">Binary_Data</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the binary data message content.</span>
<span class="c1">-- Note that only the root part of a multipart/related message is returned.</span>
<span class="kd">function</span> <span class="nf">Binary_Data</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Returns the binary data message content in a Unbounded_String</span>
<span class="c1">-- Note that only the root part of a multipart/related message is returned.</span>
<span class="kd">function</span> <span class="nf">Binary_Size</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Offset</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns size of the binary data message content</span>
<span class="kd">procedure</span> <span class="nf">Reset_Body_Index</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Reset message body read position to the start</span>
<span class="kd">procedure</span> <span class="nf">Read_Body</span>
<span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span>
<span class="nv">Buffer</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Last</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Stream_Element_Offset</span><span class="p">)</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Read a chunk of data from message body and put them into Buffer.</span>
<span class="c1">-- Last is the index of the last item returned in Buffer.</span>
<span class="kd">function</span> <span class="nf">End_Of_Body</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns true if there is no more data to read from the message body</span>
<span class="c1">-----------------</span>
<span class="c1">-- Attachments --</span>
<span class="c1">-----------------</span>
<span class="kd">function</span> <span class="nf">Attachments</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Attachments</span><span class="p">.</span><span class="n">List</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the list of Attachments for the request</span>
<span class="c1">-------------</span>
<span class="c1">-- Session --</span>
<span class="c1">-------------</span>
<span class="kd">function</span> <span class="nf">Has_Session</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns true if a session ID has been received</span>
<span class="kd">function</span> <span class="nf">Session</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Session</span><span class="p">.</span><span class="n">Id</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the Session ID for the request. Raises Constraint_Error if</span>
<span class="c1">-- server's session support not activated.</span>
<span class="kd">function</span> <span class="nf">Session_Created</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if session was just created and is going to be sent to</span>
<span class="c1">-- client.</span>
<span class="kd">function</span> <span class="nf">Session_Timed_Out</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if a previous session was timeout (even if a new session</span>
<span class="c1">-- has been created).</span>
<span class="c1">----------</span>
<span class="c1">-- SOAP --</span>
<span class="c1">----------</span>
<span class="kd">function</span> <span class="nf">Is_SOAP</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns True if it is a SOAP request. In this case SOAPAction return</span>
<span class="c1">-- the SOAPAction header and Payload returns the XML SOAP Payload message.</span>
<span class="kd">function</span> <span class="nf">SOAPAction</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Get value for "SOAPAction:" parameter. This is a standard header to</span>
<span class="c1">-- support SOAP over HTTP protocol.</span>
<span class="kd">function</span> <span class="nf">Payload</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the XML Payload message. XML payload is the actual SOAP</span>
<span class="c1">-- request. This is the root part of multipart/related SOAP message.</span>
<span class="kd">function</span> <span class="nf">Payload</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Returns the XML Payload message. XML payload is the actual SOAP</span>
<span class="c1">-- request. This is the root part of multipart/related SOAP message.</span>
<span class="c1">-----------</span>
<span class="c1">-- HTTPS --</span>
<span class="c1">-----------</span>
<span class="kd">function</span> <span class="nf">Check_Digest</span>
<span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span> <span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Messages</span><span class="p">.</span><span class="n">Status_Code</span><span class="p">;</span>
<span class="c1">-- This function is used by the digest authentication to check if the</span>
<span class="c1">-- client password and authentication parameters are correct.</span>
<span class="c1">-- The password is not transferred between the client and the server,</span>
<span class="c1">-- the server check that the client knows the right password using the</span>
<span class="c1">-- MD5 checksum.</span>
<span class="c1">-- Returns Messages.S200 in case of successful authentication,</span>
<span class="c1">-- Messages.S400 in case of wrong authentication request</span>
<span class="c1">-- (RFC 2617 3.2.2, 3.2.2.5),</span>
<span class="c1">-- and Messages.S401 in case of authentication error.</span>
<span class="kd">function</span> <span class="nf">Check_Digest</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">;</span> <span class="nv">Password</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- The same as above, but do not distinguish wrong requests and</span>
<span class="c1">-- authentication errors.</span>
<span class="kd">function</span> <span class="nf">Authorization_Mode</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Authorization_Type</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the type of the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_Name</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "username" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_URI</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "uri" value in the "Authorization:" parameter</span>
<span class="c1">-- Note, it could differ from HTTP URI field, for example Mozilla browser</span>
<span class="c1">-- places http parameters to the authorization uri field.</span>
<span class="kd">function</span> <span class="nf">Authorization_Password</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "password" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_Realm</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "realm" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_Nonce</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "nonce" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_NC</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "nc" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_CNonce</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "cnonce" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_QOP</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Retruns "qop" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_Response</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns "response" value in the "Authorization:" parameter</span>
<span class="kd">function</span> <span class="nf">Authorization_Tail</span> <span class="p">(</span><span class="nv">D</span> <span class="p">: </span><span class="nv">Data</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns precalculated part of digest composed of</span>
<span class="c1">-- Nonce, NC, CNonce, QOP, Method, URI authorization fields.</span>
<span class="c1">-- To build a full authorization response you can use:</span>
<span class="c1">--</span>
<span class="c1">-- MD5.Digest</span>
<span class="c1">-- (MD5.Digest (Username & ':' & Realm & ':' & Password)</span>
<span class="c1">-- & Authorization_Tail);</span>
<span class="c1">--</span>
<span class="c1">-- This method can be used to avoid sending a password over the network.</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.Status</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-templates">
<span id="id73"></span><h2>13.73. AWS.Templates<a class="headerlink" href="#aws-templates" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-75"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2012, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Templates_Parser</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Templates</span> <span class="kr">renames</span> <span class="nc">Templates_Parser</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-translator">
<span id="id74"></span><h2>13.74. AWS.Translator<a class="headerlink" href="#aws-translator" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-76"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Resources.Streams.Memory.ZLib</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Utils</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.Translator</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Streams</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">ZL</span> <span class="kr">renames</span> <span class="nc">AWS.Resources.Streams.Memory.ZLib</span><span class="p">;</span>
<span class="c1">------------</span>
<span class="c1">-- Base64 --</span>
<span class="c1">------------</span>
<span class="kd">type</span> <span class="kt">Base64_Mode</span> <span class="kr">is</span> <span class="p">(</span><span class="nv">MIME</span><span class="p">,</span> <span class="nv">URL</span><span class="p">);</span>
<span class="c1">-- Base64 encoding variants for encoding routines,</span>
<span class="c1">-- RFC4648</span>
<span class="c1">-- MIME - section 4</span>
<span class="c1">-- URL - section 5</span>
<span class="kd">subtype</span> <span class="kt">Base64_Common</span> <span class="kr">is</span> <span class="kt">Character</span> <span class="kr">with</span>
<span class="n">Static_Predicate</span> <span class="p">=></span> <span class="n">Base64_Common</span>
<span class="ow">in</span> <span class="p">'</span><span class="na">A</span><span class="p">'</span> <span class="p">..</span> <span class="p">'</span><span class="na">Z</span><span class="p">'</span> <span class="p">|</span> <span class="p">'</span><span class="na">a</span><span class="p">'</span> <span class="p">..</span> <span class="p">'</span><span class="na">z</span><span class="p">'</span> <span class="p">|</span> <span class="p">'</span><span class="na">0</span><span class="p">'</span> <span class="p">..</span> <span class="p">'</span><span class="na">9</span><span class="p">'</span> <span class="p">|</span> <span class="s s-Character">'='</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Base64_String</span> <span class="kr">is</span> <span class="kt">String</span> <span class="kr">with</span>
<span class="n">Dynamic_Predicate</span> <span class="p">=></span>
<span class="p">(</span><span class="nv">for</span> <span class="nv">all</span> <span class="nv">C</span> <span class="nv">of</span> <span class="nv">Base64_String</span> <span class="p">=></span>
<span class="nv">C</span> <span class="nv">in</span> <span class="nv">Base64_Common</span> <span class="p">|</span> <span class="s s-Character">'+'</span> <span class="p">|</span> <span class="s s-Character">'-'</span> <span class="p">|</span> <span class="p">'</span><span class="na">_</span><span class="p">'</span> <span class="p">|</span> <span class="s s-Character">'/'</span><span class="p">);</span>
<span class="kd">subtype</span> <span class="kt">Base64_UString</span> <span class="kr">is</span> <span class="n">Unbounded_String</span> <span class="kr">with</span>
<span class="n">Dynamic_Predicate</span> <span class="p">=></span>
<span class="p">(</span><span class="nv">for</span> <span class="nv">all</span> <span class="nv">K</span> <span class="nv">in</span> <span class="nv">1</span> <span class="p">..</span> <span class="nv">Length</span> <span class="p">(</span><span class="nv">Base64_UString</span><span class="p">)</span> <span class="p">=></span>
<span class="n">Element</span> <span class="p">(</span><span class="nv">Base64_UString</span><span class="p">,</span> <span class="nv">K</span><span class="p">)</span>
<span class="ow">in</span> <span class="n">Base64_Common</span> <span class="p">|</span> <span class="s s-Character">'+'</span> <span class="p">|</span> <span class="s s-Character">'-'</span> <span class="p">|</span> <span class="p">'</span><span class="na">_</span><span class="p">'</span> <span class="p">|</span> <span class="s s-Character">'/'</span><span class="p">);</span>
<span class="c1">--</span>
<span class="c1">-- Decoding does not have to have Base64_Mode parameter, because data</span>
<span class="c1">-- coding easy detected automatically.</span>
<span class="kd">procedure</span> <span class="nf">Base64_Encode</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">B64_Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Base64_UString</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Base64_Mode</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">)</span>
<span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span>
<span class="p">(</span><span class="n">Mode</span> <span class="o">=</span> <span class="n">MIME</span>
<span class="ow">and then</span>
<span class="p">(</span><span class="kr">for</span> <span class="kr">all</span> <span class="n">K</span> <span class="ow">in</span> <span class="mi">1</span> <span class="p">..</span> <span class="n">Length</span> <span class="p">(</span><span class="n">B64_Data</span><span class="p">)</span> <span class="p">=></span>
<span class="n">Element</span> <span class="p">(</span><span class="n">B64_Data</span><span class="p">,</span> <span class="n">K</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="s s-Character">'-'</span> <span class="p">|</span> <span class="p">'</span><span class="na">_</span><span class="p">'))</span>
<span class="ow">or else</span>
<span class="p">(</span><span class="n">Mode</span> <span class="o">=</span> <span class="n">URL</span>
<span class="ow">and then</span>
<span class="p">(</span><span class="kr">for</span> <span class="kr">all</span> <span class="n">K</span> <span class="ow">in</span> <span class="mi">1</span> <span class="p">..</span> <span class="n">Length</span> <span class="p">(</span><span class="n">B64_Data</span><span class="p">)</span> <span class="p">=></span>
<span class="n">Element</span> <span class="p">(</span><span class="n">B64_Data</span><span class="p">,</span> <span class="n">K</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="s s-Character">'+'</span> <span class="p">|</span> <span class="s s-Character">'/'</span><span class="p">));</span>
<span class="kd">function</span> <span class="nf">Base64_Encode</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Mode</span> <span class="p">: </span><span class="nv">Base64_Mode</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Base64_String</span>
<span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span>
<span class="p">(</span><span class="n">Mode</span> <span class="o">=</span> <span class="n">MIME</span>
<span class="ow">and then</span>
<span class="p">(</span><span class="kr">for</span> <span class="kr">all</span> <span class="n">C</span> <span class="kr">of</span> <span class="n">Base64_Encode</span><span class="p">'</span><span class="na">Result</span> <span class="p">=></span> <span class="n">C</span> <span class="ow">not</span> <span class="ow">in</span> <span class="s s-Character">'-'</span> <span class="p">|</span> <span class="p">'</span><span class="na">_</span><span class="p">'))</span>
<span class="ow">or else</span>
<span class="p">(</span><span class="n">Mode</span> <span class="o">=</span> <span class="n">URL</span>
<span class="ow">and then</span>
<span class="p">(</span><span class="kr">for</span> <span class="kr">all</span> <span class="n">C</span> <span class="kr">of</span> <span class="n">Base64_Encode</span><span class="p">'</span><span class="na">Result</span> <span class="p">=></span> <span class="n">C</span> <span class="ow">not</span> <span class="ow">in</span> <span class="s s-Character">'+'</span> <span class="p">|</span> <span class="s s-Character">'/'</span><span class="p">));</span>
<span class="c1">-- Encode Data using the base64 algorithm</span>
<span class="kd">function</span> <span class="nf">Base64_Encode</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Mode</span> <span class="p">: </span><span class="nv">Base64_Mode</span> <span class="p">:=</span> <span class="nv">MIME</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Base64_String</span>
<span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span>
<span class="p">(</span><span class="n">Mode</span> <span class="o">=</span> <span class="n">MIME</span>
<span class="ow">and then</span>
<span class="p">(</span><span class="kr">for</span> <span class="kr">all</span> <span class="n">C</span> <span class="kr">of</span> <span class="n">Base64_Encode</span><span class="p">'</span><span class="na">Result</span> <span class="p">=></span> <span class="n">C</span> <span class="ow">not</span> <span class="ow">in</span> <span class="s s-Character">'-'</span> <span class="p">|</span> <span class="p">'</span><span class="na">_</span><span class="p">'))</span>
<span class="ow">or else</span>
<span class="p">(</span><span class="n">Mode</span> <span class="o">=</span> <span class="n">URL</span>
<span class="ow">and then</span>
<span class="p">(</span><span class="kr">for</span> <span class="kr">all</span> <span class="n">C</span> <span class="kr">of</span> <span class="n">Base64_Encode</span><span class="p">'</span><span class="na">Result</span> <span class="p">=></span> <span class="n">C</span> <span class="ow">not</span> <span class="ow">in</span> <span class="s s-Character">'+'</span> <span class="p">|</span> <span class="s s-Character">'/'</span><span class="p">));</span>
<span class="c1">-- Same as above but takes a string as input</span>
<span class="kd">procedure</span> <span class="nf">Base64_Decode</span>
<span class="p">(</span><span class="nv">B64_Data</span> <span class="p">: </span><span class="nv">Base64_UString</span><span class="p">;</span>
<span class="nv">Data</span> <span class="p">: </span><span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Base64_Decode</span>
<span class="p">(</span><span class="nv">B64_Data</span> <span class="p">: </span><span class="nv">Base64_String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span><span class="p">;</span>
<span class="c1">-- Decode B64_Data using the base64 algorithm</span>
<span class="kd">function</span> <span class="nf">Base64_Decode</span> <span class="p">(</span><span class="nv">B64_Data</span> <span class="p">: </span><span class="nv">Base64_String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">--------</span>
<span class="c1">-- QP --</span>
<span class="c1">--------</span>
<span class="kd">function</span> <span class="nf">QP_Decode</span> <span class="p">(</span><span class="nv">QP_Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Decode QP_Data using the Quoted Printable algorithm</span>
<span class="c1">------------------------------------</span>
<span class="c1">-- String to Stream_Element_Array --</span>
<span class="c1">------------------------------------</span>
<span class="kd">function</span> <span class="nf">To_String</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Convert a Stream_Element_Array to a string. Note that as this routine</span>
<span class="c1">-- returns a String it should not be used with large array as this could</span>
<span class="c1">-- break the stack size limit. Use the routine below for large array.</span>
<span class="kd">function</span> <span class="nf">To_Stream_Element_Array</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Stream_Element_Array</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Convert a String to a Stream_Element_Array</span>
<span class="kd">function</span> <span class="nf">To_Unbounded_String</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Convert a Stream_Element_Array to an Unbounded_String</span>
<span class="c1">--------------------------</span>
<span class="c1">-- Compress/Decompress --</span>
<span class="c1">--------------------------</span>
<span class="kd">subtype</span> <span class="kt">Compression_Level</span> <span class="kr">is</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Compression_Level</span><span class="p">;</span>
<span class="no">Default_Compression</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Compression_Level</span> <span class="p">:=</span> <span class="n">ZL</span><span class="p">.</span><span class="n">Default_Compression</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Compress</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Level</span> <span class="p">: </span><span class="nv">Compression_Level</span> <span class="p">:=</span> <span class="nv">Default_Compression</span><span class="p">;</span>
<span class="nv">Header</span> <span class="p">: </span><span class="nv">ZL</span><span class="p">.</span><span class="nv">Header_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Header</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Utils</span><span class="p">.</span><span class="n">Stream_Element_Array_Access</span><span class="p">;</span>
<span class="c1">-- Returns Data compressed with a standard deflate algorithm based on the</span>
<span class="c1">-- zlib library. The result is dynamically allocated and must be</span>
<span class="c1">-- explicitly freed.</span>
<span class="kd">function</span> <span class="nf">Decompress</span>
<span class="p">(</span><span class="nv">Data</span> <span class="p">: </span><span class="nv">Stream_Element_Array</span><span class="p">;</span>
<span class="nv">Header</span> <span class="p">: </span><span class="nv">ZL</span><span class="p">.</span><span class="nv">Header_Type</span> <span class="p">:=</span> <span class="nv">ZL</span><span class="p">.</span><span class="nv">Default_Header</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Utils</span><span class="p">.</span><span class="n">Stream_Element_Array_Access</span><span class="p">;</span>
<span class="c1">-- Returns Data decompressed based on the zlib library. The results is</span>
<span class="c1">-- dynamically allocated and must be explicitly freed.</span>
<span class="kr">end</span> <span class="nf">AWS.Translator</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="aws-url">
<span id="id75"></span><h2>13.75. AWS.URL<a class="headerlink" href="#aws-url" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-77"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Maps</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Parameters</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">AWS.URL</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="c1">-- The general URL form as described in RFC2616 is:</span>
<span class="c1">--</span>
<span class="c1">-- http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]</span>
<span class="c1">--</span>
<span class="c1">-- Note also that there are different RFC describing URL like the 2616 and</span>
<span class="c1">-- 1738 but they use different terminologies. Here we try to follow the</span>
<span class="c1">-- names used in RFC2616 but we have implemented some extensions at the</span>
<span class="c1">-- end of this package. For example the way Path and File are separated or</span>
<span class="c1">-- the handling of user/password which is explicitly not allowed in the</span>
<span class="c1">-- RFC but are used and supported in many browsers. Here are the extended</span>
<span class="c1">-- URL supported:</span>
<span class="c1">--</span>
<span class="c1">-- http://user:pass@www.here.com:80/dir1/dir2/xyz.html?p=8&x=doh#anchor</span>
<span class="c1">-- | | | | | | |</span>
<span class="c1">-- protocol host port path file parameters fragment</span>
<span class="c1">--</span>
<span class="c1">-- <-- pathname --></span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="n">URL_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="no">Default_FTP_Port</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">21</span><span class="p">;</span>
<span class="no">Default_HTTP_Port</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">80</span><span class="p">;</span>
<span class="no">Default_HTTPS_Port</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">443</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Parse</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Check_Validity</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Normalize</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Parse an URL and return an Object representing this URL. It is then</span>
<span class="c1">-- possible to extract each part of the URL with the services bellow.</span>
<span class="c1">-- Raises URL_Error if Check_Validity is true and the URL reference a</span>
<span class="c1">-- resource above the web root directory.</span>
<span class="kd">procedure</span> <span class="nf">Normalize</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Removes all occurrences to parent directory ".." and current directory</span>
<span class="c1">-- ".". Raises URL_Error if the URL reference a resource above the Web</span>
<span class="c1">-- root directory.</span>
<span class="kd">function</span> <span class="nf">Is_Valid</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the URL is valid (does not reference directory above</span>
<span class="c1">-- the Web root).</span>
<span class="kd">function</span> <span class="nf">URL</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns full URL string, this can be different to the URL passed if it</span>
<span class="c1">-- has been normalized.</span>
<span class="kd">function</span> <span class="nf">Protocol_Name</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns "http" or "https" depending on the protocol used by URL</span>
<span class="kd">function</span> <span class="nf">Host</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">IPv6_Brackets</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the hostname in IPv6 breakets if necessary</span>
<span class="kd">function</span> <span class="nf">Port</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Positive</span><span class="p">;</span>
<span class="c1">-- Returns the port as a positive</span>
<span class="kd">function</span> <span class="nf">Port</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the port as a string</span>
<span class="kd">function</span> <span class="nf">Port_Not_Default</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the port image (preceded by character ':') if it is not the</span>
<span class="c1">-- default port. Returns the empty string otherwise.</span>
<span class="kd">function</span> <span class="nf">Abs_Path</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the absolute path. This is the complete resource reference</span>
<span class="c1">-- without the query part.</span>
<span class="kd">function</span> <span class="nf">Query</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the Query part of the URL or the empty string if none was</span>
<span class="c1">-- specified. Note that character '?' is not part of the Query and is</span>
<span class="c1">-- therefore not returned.</span>
<span class="c1">--</span>
<span class="c1">-- Below are extended API not part of the RFC 2616 URL specification</span>
<span class="c1">--</span>
<span class="kd">function</span> <span class="nf">User</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns user name part of the URL. Returns the empty string if user was</span>
<span class="c1">-- not specified.</span>
<span class="kd">function</span> <span class="nf">Password</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns user's password part of the URL. Returns the empty string if</span>
<span class="c1">-- password was not specified.</span>
<span class="kd">function</span> <span class="nf">Server_Name</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">IPv6_Brackets</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kr">renames</span> <span class="n">Host</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Security</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if it is a Secure HTTP (HTTPS) URL</span>
<span class="kd">function</span> <span class="nf">Path</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the Path (including the leading slash). If Encode is True then</span>
<span class="c1">-- the URL will be encoded using the Encode routine.</span>
<span class="kd">function</span> <span class="nf">File</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the File. If Encode is True then the URL will be encoded using</span>
<span class="c1">-- the Encode routine. Not that by File here we mean the latest part of</span>
<span class="c1">-- the URL, it could be a real file or a diretory into the filesystem.</span>
<span class="c1">-- Parent and current directories are part of the path.</span>
<span class="kd">function</span> <span class="nf">Parameters</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the Parameters (including the starting ? character). If Encode</span>
<span class="c1">-- is True then the URL will be encoded using the Encode routine.</span>
<span class="kd">function</span> <span class="nf">Pathname</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">Abs_Path</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Pathname_And_Parameters</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Encode</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the pathname and the parameters. This is equivalent to:</span>
<span class="c1">-- Pathname & Parameters.</span>
<span class="kd">function</span> <span class="nf">Parameter</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span> <span class="p">:=</span> <span class="nv">1</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns the Nth value associated with Key into Table. Returns</span>
<span class="c1">-- the emptry string if key does not exist.</span>
<span class="kd">function</span> <span class="nf">Parameters</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Parameters</span><span class="p">.</span><span class="n">List</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Return the parameter list associated with the URL</span>
<span class="kd">function</span> <span class="nf">Fragment</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Return the part after the # sign (included)</span>
<span class="c1">--</span>
<span class="c1">-- URL Resolution</span>
<span class="c1">--</span>
<span class="kd">function</span> <span class="nf">Resolve</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span> <span class="nv">Base_URL</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Resolve an URL relative to a Base_URL. Uses RFC 3986, section 5.2</span>
<span class="c1">-- algorithm.</span>
<span class="kd">function</span> <span class="nf">Resolve</span> <span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span> <span class="nv">Base_URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Resolve an URL relatively to a Base_URL. Same function as above, but</span>
<span class="c1">-- working with Strings.</span>
<span class="c1">--</span>
<span class="c1">-- URL Encoding and Decoding</span>
<span class="c1">--</span>
<span class="no">Parameters_Encoding_Set</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Strings</span><span class="p">.</span><span class="n">Maps</span><span class="p">.</span><span class="n">Character_Set</span><span class="p">;</span>
<span class="c1">-- Encoding set enought for HTTP parameters</span>
<span class="no">Default_Encoding_Set</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Strings</span><span class="p">.</span><span class="n">Maps</span><span class="p">.</span><span class="n">Character_Set</span><span class="p">;</span>
<span class="c1">-- Encoding set enought for all URL parts</span>
<span class="kd">function</span> <span class="nf">Encode</span>
<span class="p">(</span><span class="nv">Str</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Encoding_Set</span> <span class="p">: </span><span class="nv">Strings</span><span class="p">.</span><span class="nv">Maps</span><span class="p">.</span><span class="nv">Character_Set</span> <span class="p">:=</span> <span class="nv">Default_Encoding_Set</span><span class="p">)</span>
<span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Encode Str into a URL-safe form. Many characters are forbiden into an</span>
<span class="c1">-- URL and needs to be encoded. A character is encoded by %XY where XY is</span>
<span class="c1">-- the character's ASCII hexadecimal code. For example a space is encoded</span>
<span class="c1">-- as %20.</span>
<span class="kd">function</span> <span class="nf">Decode</span> <span class="p">(</span><span class="nv">Str</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- This is the opposite of Encode above</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">AWS.URL</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap">
<span id="id76"></span><h2>13.76. SOAP<a class="headerlink" href="#soap" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-78"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kd">package</span> <span class="nc">SOAP</span> <span class="kr">is</span>
<span class="c1">-- This is the root package for the SOAP implementation. It supports</span>
<span class="c1">-- SOAP 1.1 specifications.</span>
<span class="n">SOAP_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Will be raised when an error occurs in the SOAP implementation. The</span>
<span class="c1">-- exception message will described the problem.</span>
<span class="no">Version</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"2.0.0"</span><span class="p">;</span>
<span class="c1">-- Version number for this implementation</span>
<span class="no">No_SOAPAction</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="p">(</span><span class="mi">1</span> <span class="p">=></span> <span class="n">ASCII</span><span class="p">.</span><span class="n">NUL</span><span class="p">);</span>
<span class="c1">-- Value used to specify that there was no SOAPAction specified</span>
<span class="kr">end</span> <span class="nf">SOAP</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-client">
<span id="id77"></span><h2>13.77. SOAP.Client<a class="headerlink" href="#soap-client" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-79"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Client</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Message.Payload</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Message.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.WSDL.Schema</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Client</span> <span class="kr">is</span>
<span class="n">Not_Specified</span> <span class="p">:</span> <span class="kt">String</span> <span class="kr">renames</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Client</span><span class="p">.</span><span class="n">No_Data</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Call</span>
<span class="p">(</span><span class="nv">URL</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">P</span> <span class="p">: </span><span class="nv">Message</span><span class="p">.</span><span class="nv">Payload</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">No_SOAPAction</span><span class="p">;</span>
<span class="nv">User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Proxy</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Proxy_User</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Proxy_Pwd</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">Not_Specified</span><span class="p">;</span>
<span class="nv">Timeouts</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Client</span><span class="p">.</span><span class="nv">Timeouts_Values</span> <span class="p">:=</span> <span class="nv">AWS</span><span class="p">.</span><span class="nv">Client</span><span class="p">.</span><span class="nv">No_Timeout</span><span class="p">;</span>
<span class="nv">Asynchronous</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">URL</span><span class="p">'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Send a SOAP HTTP request to URL address. The P is the Payload and</span>
<span class="c1">-- SOAPAction is the required HTTP field. If it is not specified then the</span>
<span class="c1">-- URI (URL resource) will be used for the SOAPAction field. The complete</span>
<span class="c1">-- format is "URL & '#' & Procedure_Name" (Procedure_Name is retrieved</span>
<span class="c1">-- from the Payload object.</span>
<span class="c1">--</span>
<span class="c1">-- If Asynchronous is set to True the response from the server may be</span>
<span class="c1">-- empty. In this specific case the success of the call depends on the</span>
<span class="c1">-- HTTP status code.</span>
<span class="kd">function</span> <span class="nf">Call</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Client</span><span class="p">.</span><span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">P</span> <span class="p">: </span><span class="nv">Message</span><span class="p">.</span><span class="nv">Payload</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Asynchronous</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">False</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span>
<span class="kn">with</span> <span class="nn">Pre</span> <span class="p">=></span> <span class="n">AWS</span><span class="p">.</span><span class="n">Client</span><span class="p">.</span><span class="n">Host</span> <span class="p">(</span><span class="n">Connection</span><span class="p">)'</span><span class="na">Length</span> <span class="o">></span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">-- Idem as above, but use an already opened connection</span>
<span class="kr">end</span> <span class="nf">SOAP.Client</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-dispatchers">
<span id="id78"></span><h2>13.78. SOAP.Dispatchers<a class="headerlink" href="#soap-dispatchers" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-80"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Dispatcher for SOAP requests</span>
<span class="kn">with</span> <span class="nn">AWS.Dispatchers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Status</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Message.Payload</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.WSDL.Schema</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Dispatchers</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">new</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- This dispatcher will send SOAP and HTTP requests to different routines</span>
<span class="kd">function</span> <span class="nf">Schema</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Handler</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">WSDL</span><span class="p">.</span><span class="n">Schema</span><span class="p">.</span><span class="n">Definition</span><span class="p">;</span>
<span class="c1">-- Returns the schema for the given SOAPAction</span>
<span class="kd">type</span> <span class="kt">SOAP_Callback</span> <span class="kr">is</span>
<span class="kr">access</span> <span class="kd">function</span> <span class="p">(</span><span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Payload</span> <span class="p">: </span><span class="nv">Message</span><span class="p">.</span><span class="nv">Payload</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Data</span><span class="p">;</span>
<span class="c1">-- This is the SOAP Server callback type. SOAPAction is the HTTP header</span>
<span class="c1">-- SOAPAction value, Payload is the parsed XML payload, request is the</span>
<span class="c1">-- HTTP request status.</span>
<span class="kd">function</span> <span class="nf">Dispatch_SOAP</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Handler</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Payload</span> <span class="p">: </span><span class="nv">Message</span><span class="p">.</span><span class="nv">Payload</span><span class="p">.</span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Data</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- This dispatch function is called for SOAP requests</span>
<span class="kd">function</span> <span class="nf">Dispatch_HTTP</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Handler</span><span class="p">;</span>
<span class="nv">Request</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Status</span><span class="p">.</span><span class="nv">Data</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">AWS</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Data</span> <span class="kr">is</span> <span class="kr">abstract</span><span class="p">;</span>
<span class="c1">-- This dispatch function is called for standard HTTP requests</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">SOAP.Dispatchers</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-dispatchers-callback">
<span id="id79"></span><h2>13.79. SOAP.Dispatchers.Callback<a class="headerlink" href="#soap-dispatchers-callback" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-81"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2003-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Dispatch on a SOAP Callback procedures</span>
<span class="kn">with</span> <span class="nn">SOAP.Message</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.WSDL.Schema</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Dispatchers.Callback</span> <span class="kr">is</span>
<span class="kd">type</span> <span class="kt">Handler</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Dispatchers</span><span class="p">.</span><span class="n">Handler</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- This is a simple wrapper around standard callback procedure (access to</span>
<span class="c1">-- function). It will be used to build dispatchers services and for the</span>
<span class="c1">-- main server callback.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Schema</span>
<span class="p">(</span><span class="nv">Dispatcher</span> <span class="p">: </span><span class="nv">Handler</span><span class="p">;</span>
<span class="nv">SOAPAction</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">WSDL</span><span class="p">.</span><span class="n">Schema</span><span class="p">.</span><span class="n">Definition</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Create</span>
<span class="p">(</span><span class="nv">HTTP_Callback</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Response</span><span class="p">.</span><span class="nv">Callback</span><span class="p">;</span>
<span class="nv">SOAP_Callback</span> <span class="p">: </span><span class="nv">Dispatchers</span><span class="p">.</span><span class="nv">SOAP_Callback</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span>
<span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Handler</span><span class="p">;</span>
<span class="c1">-- Build a dispatcher for the specified callback</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">SOAP.Dispatchers.Callback</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-message">
<span id="id80"></span><h2>13.80. SOAP.Message<a class="headerlink" href="#soap-message" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-82"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Name_Space</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Parameters</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.WSDL.Schema</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Message</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Returns the XML image for the wrapper and parameters. This is designed</span>
<span class="c1">-- to be used by Payload and Response object.</span>
<span class="kd">function</span> <span class="nf">Name_Space</span> <span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">SOAP</span><span class="p">.</span><span class="n">Name_Space</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Returns message Namespace</span>
<span class="kd">function</span> <span class="nf">Wrapper_Name</span> <span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns wrapper name</span>
<span class="kd">function</span> <span class="nf">Parameters</span> <span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">SOAP</span><span class="p">.</span><span class="n">Parameters</span><span class="p">.</span><span class="n">List</span><span class="p">;</span>
<span class="c1">-- Returns the parameter</span>
<span class="kd">procedure</span> <span class="nf">Set_Name_Space</span>
<span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">SOAP</span><span class="p">.</span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Set message's Namespace</span>
<span class="kd">procedure</span> <span class="nf">Set_Wrapper_Name</span>
<span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set message's wrapper name</span>
<span class="kd">procedure</span> <span class="nf">Set_Parameters</span>
<span class="p">(</span><span class="nv">M</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">P_Set</span> <span class="p">: </span><span class="nv">SOAP</span><span class="p">.</span><span class="nv">Parameters</span><span class="p">.</span><span class="nv">List</span><span class="p">);</span>
<span class="c1">-- Set message's parameters</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">SOAP.Message</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-message-xml">
<span id="id81"></span><h2>13.81. SOAP.Message.XML<a class="headerlink" href="#soap-message-xml" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-83"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2015, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">AWS.Client</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Message.Payload</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Message.Response</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.WSDL.Schema</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Message.XML</span> <span class="kr">is</span>
<span class="n">SOAP_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">SOAP</span><span class="p">.</span><span class="n">SOAP_Error</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Load_Payload</span>
<span class="p">(</span><span class="nv">XML</span> <span class="p">: </span><span class="nv">aliased</span> <span class="nv">String</span><span class="p">;</span>
<span class="nv">Envelope</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Payload</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Build a Payload object by parsing the XML payload string.</span>
<span class="c1">-- If Envelope is False, the message could consists only from body</span>
<span class="c1">-- with arbitrary named root tag without mandatory SOAP Envelope wrapper.</span>
<span class="kd">function</span> <span class="nf">Load_Payload</span>
<span class="p">(</span><span class="nv">XML</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Envelope</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Payload</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Build a Payload object by parsing the XML payload string</span>
<span class="kd">function</span> <span class="nf">Load_Response</span>
<span class="p">(</span><span class="nv">Connection</span> <span class="p">: </span><span class="nv">AWS</span><span class="p">.</span><span class="nv">Client</span><span class="p">.</span><span class="nv">HTTP_Connection</span><span class="p">;</span>
<span class="nv">Envelope</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Build a Response object (either a standard response or an error</span>
<span class="c1">-- response) by parsing the HTTP client connection output.</span>
<span class="c1">-- If Envelope is False, the message could consists only from body</span>
<span class="c1">-- with arbitrary named root tag without mandatory SOAP Envelope wrapper.</span>
<span class="kd">function</span> <span class="nf">Load_Response</span>
<span class="p">(</span><span class="nv">XML</span> <span class="p">: </span><span class="nv">aliased</span> <span class="nv">String</span><span class="p">;</span>
<span class="nv">Envelope</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Build a Response object (either a standard response or an error</span>
<span class="c1">-- response) by parsing the XML response string.</span>
<span class="c1">-- If Envelope is False, the message could consists only from body</span>
<span class="c1">-- with arbitrary named root tag without mandatory SOAP Envelope wrapper.</span>
<span class="kd">function</span> <span class="nf">Load_Response</span>
<span class="p">(</span><span class="nv">XML</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Envelope</span> <span class="p">: </span><span class="nv">Boolean</span> <span class="p">:=</span> <span class="nv">True</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">Message</span><span class="p">.</span><span class="n">Response</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- As above but using an Unbounded_String</span>
<span class="kd">function</span> <span class="nf">Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns XML representation of object O</span>
<span class="kd">function</span> <span class="nf">Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span>
<span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- Idem as above but returns an Unbounded_String instead of a String</span>
<span class="kr">end</span> <span class="nf">SOAP.Message.XML</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-parameters">
<span id="id82"></span><h2>13.82. SOAP.Parameters<a class="headerlink" href="#soap-parameters" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-84"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2000-2014, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Types</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Parameters</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="n">Data_Error</span> <span class="p">:</span> <span class="kr">exception</span> <span class="kr">renames</span> <span class="n">Types</span><span class="p">.</span><span class="n">Data_Error</span><span class="p">;</span>
<span class="no">Max_Parameters</span> <span class="p">:</span> <span class="kr">constant</span> <span class="p">:=</span> <span class="mi">50</span><span class="p">;</span>
<span class="c1">-- This is the maximum number of parameters supported by this</span>
<span class="c1">-- implementation.</span>
<span class="kd">type</span> <span class="kt">List</span> <span class="kr">is</span> <span class="kd">private</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Argument_Count</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="n">Argument_Count</span><span class="p">'</span><span class="na">Result</span> <span class="o"><=</span> <span class="n">Max_Parameters</span><span class="p">;</span>
<span class="c1">-- Returns the number of parameters in P</span>
<span class="kd">function</span> <span class="nf">Argument</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Returns parameters named Name in P. Raises Types.Data_Error if not</span>
<span class="c1">-- found.</span>
<span class="kd">function</span> <span class="nf">Argument</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Returns Nth parameters in P. Raises Types.Data_Error if not found</span>
<span class="kd">function</span> <span class="nf">Exist</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if parameter named Name exist in P and False otherwise</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Long</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Long value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a Long.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as an Integer value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not an Integer.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Short</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Short value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not an Short.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="kt">Byte</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Byte value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a Byte.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Float</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Float value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a Float.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Long_Float</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Float value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a Double.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a String value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a String.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Idem as above, but return an Unbounded_String</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Boolean value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a Boolean.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Time value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a time.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Unsigned_Long</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Unsigned_Long value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not an</span>
<span class="c1">-- Unsigned_Long.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Unsigned_Int</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Unsigned_Int value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not an</span>
<span class="c1">-- Unsigned_Int.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Unsigned_Short</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Unsigned_Short value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not an</span>
<span class="c1">-- Unsigned_Short.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">Unsigned_Byte</span>
<span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a Unsigned_Byte value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not an</span>
<span class="c1">-- Unsigned_Byte.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">SOAP_Base64</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a SOAP Base64 value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a SOAP</span>
<span class="c1">-- Base64.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">SOAP_Record</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a SOAP Struct value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a SOAP</span>
<span class="c1">-- Struct.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Types</span><span class="p">.</span><span class="n">SOAP_Array</span> <span class="kn">with</span> <span class="nn">Inline</span><span class="p">;</span>
<span class="c1">-- Returns parameter named Name in P as a SOAP Array value. Raises</span>
<span class="c1">-- Types.Data_Error if this parameter does not exist or is not a SOAP</span>
<span class="c1">-- Array.</span>
<span class="c1">------------------</span>
<span class="c1">-- Constructors --</span>
<span class="c1">------------------</span>
<span class="kd">function</span> <span class="nf">"&"</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">O</span> <span class="p">: </span><span class="nv">Types</span><span class="p">.</span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">List</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="n">Argument_Count</span> <span class="p">(</span><span class="s">"&"</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="n">Argument_Count</span> <span class="p">(</span><span class="n">P</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">"+"</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Types</span><span class="p">.</span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">List</span> <span class="kn">with</span>
<span class="nn">Post</span> <span class="p">=></span> <span class="n">Argument_Count</span> <span class="p">(</span><span class="s">"+"</span><span class="p">'</span><span class="na">Result</span><span class="p">)</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">----------------</span>
<span class="c1">-- Validation --</span>
<span class="c1">----------------</span>
<span class="kd">procedure</span> <span class="nf">Check</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Natural</span><span class="p">);</span>
<span class="c1">-- Checks that there is exactly N parameters or raise Types.Data_Error</span>
<span class="kd">procedure</span> <span class="nf">Check_Integer</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is an Integer value</span>
<span class="kd">procedure</span> <span class="nf">Check_Float</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is a Float value</span>
<span class="kd">procedure</span> <span class="nf">Check_Boolean</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is a Boolean value</span>
<span class="kd">procedure</span> <span class="nf">Check_Time_Instant</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is a Time_Instant value</span>
<span class="kd">procedure</span> <span class="nf">Check_Base64</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is a Base64 value</span>
<span class="kd">procedure</span> <span class="nf">Check_Null</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is a Null value</span>
<span class="kd">procedure</span> <span class="nf">Check_Record</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is a Record value</span>
<span class="kd">procedure</span> <span class="nf">Check_Array</span> <span class="p">(</span><span class="nv">P</span> <span class="p">: </span><span class="nv">List</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Checks that parameter named Name exist and is an Array value</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">SOAP.Parameters</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="soap-types">
<span id="id83"></span><h2>13.83. SOAP.Types<a class="headerlink" href="#soap-types" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ada" id="index-85"><div class="highlight"><pre><span></span><span class="c1">------------------------------------------------------------------------------</span>
<span class="c1">-- Ada Web Server --</span>
<span class="c1">-- --</span>
<span class="c1">-- Copyright (C) 2001-2016, AdaCore --</span>
<span class="c1">-- --</span>
<span class="c1">-- This library is free software; you can redistribute it and/or modify --</span>
<span class="c1">-- it under terms of the GNU General Public License as published by the --</span>
<span class="c1">-- Free Software Foundation; either version 3, or (at your option) any --</span>
<span class="c1">-- later version. This library is distributed in the hope that it will be --</span>
<span class="c1">-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --</span>
<span class="c1">-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- You should have received a copy of the GNU General Public License and --</span>
<span class="c1">-- a copy of the GCC Runtime Library Exception along with this program; --</span>
<span class="c1">-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --</span>
<span class="c1">-- <http://www.gnu.org/licenses/>. --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">-- --</span>
<span class="c1">------------------------------------------------------------------------------</span>
<span class="kr">pragma</span> <span class="cp">Ada_2012</span><span class="p">;</span>
<span class="c1">-- This package contains all SOAP types supported by this implementation.</span>
<span class="c1">-- Here are some notes about adding support for a new SOAP type (not a</span>
<span class="c1">-- container) and the corresponding WSDL support:</span>
<span class="c1">--</span>
<span class="c1">-- 1. Add new type derived from scalar in this package. Implements all</span>
<span class="c1">-- inherited routines (Image, XML_Image and XML_Type). Implements also</span>
<span class="c1">-- a constructor for this new type and a routine named V to get the</span>
<span class="c1">-- value as an Ada type.</span>
<span class="c1">--</span>
<span class="c1">-- 2. In SOAP.Parameters add corresponding Get routine.</span>
<span class="c1">--</span>
<span class="c1">-- 3. In SOAP.WSDL, add the new type name in Parameter_Type.</span>
<span class="c1">--</span>
<span class="c1">-- 4. Add support for this new type in all SOAP.WSDL routines. All routines</span>
<span class="c1">-- are using a case statement to be sure that it won't compile without</span>
<span class="c1">-- fixing it first. For obvious reasons, only SOAP.WSDL.To_Type and</span>
<span class="c1">-- SOAP.WSDL.From_Ada are not using a case statement, be sure to do the</span>
<span class="c1">-- right Change There.</span>
<span class="c1">--</span>
<span class="c1">-- 5. Finaly add support for this type in SOAP.Message.XML. Add this type</span>
<span class="c1">-- into Type_State, write the corresponding parse procedure and fill entry</span>
<span class="c1">-- into Handlers. Again after adding the proper type into Type_State the</span>
<span class="c1">-- compiler will issue errors where changes are needed.</span>
<span class="kn">with</span> <span class="nn">Ada.Calendar</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Finalization</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.Name_Space</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">SOAP.WSDL.Schema</span><span class="p">;</span>
<span class="kd">package</span> <span class="nc">SOAP.Types</span> <span class="kr">is</span>
<span class="kn">use</span> <span class="nn">Ada</span><span class="p">;</span>
<span class="kn">use</span> <span class="nn">Ada.Strings.Unbounded</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">Encoding_Style</span> <span class="kr">is</span> <span class="n">WSDL</span><span class="p">.</span><span class="n">Schema</span><span class="p">.</span><span class="n">Encoding_Style</span><span class="p">;</span>
<span class="c1">-- SOAP encoding style for the entities</span>
<span class="n">Data_Error</span> <span class="p">:</span> <span class="kr">exception</span><span class="p">;</span>
<span class="c1">-- Raised when a variable has not the expected type</span>
<span class="kd">type</span> <span class="kt">Object</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Root type for all SOAP types defined in this package</span>
<span class="kd">type</span> <span class="kt">Object_Access</span> <span class="kr">is</span> <span class="kr">access</span> <span class="kr">all</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">Object_Safe_Pointer</span> <span class="kr">is</span> <span class="kr">tagged</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- A safe pointer to a SOAP object, such objects are controlled so the</span>
<span class="c1">-- memory is freed automatically.</span>
<span class="kd">type</span> <span class="kt">Object_Set</span> <span class="kr">is</span> <span class="kr">array</span> <span class="p">(</span><span class="kt">Positive</span> <span class="kr">range</span> <span class="p"><>)</span> <span class="kr">of</span> <span class="n">Object_Safe_Pointer</span><span class="p">;</span>
<span class="c1">-- A set of SOAP types. This is used to build arrays or records. We use</span>
<span class="c1">-- Positive for the index to have the item index map the SOAP array</span>
<span class="c1">-- element order.</span>
<span class="no">Empty_Object_Set</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">Object_Set</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns O value image</span>
<span class="kd">function</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the object is empty Array, Empty Record or null value</span>
<span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="c1">-- Returns O value encoded for use by the Payload object or Response</span>
<span class="c1">-- object. The generated characters are appened to Result.</span>
<span class="kd">function</span> <span class="nf">XML_Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns O value encoded for use by the Payload object or Response</span>
<span class="c1">-- object.</span>
<span class="kd">function</span> <span class="nf">XML_Type</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the XML type for the object</span>
<span class="kd">function</span> <span class="nf">Name</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns name for object O</span>
<span class="kd">function</span> <span class="nf">Type_Name</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns the type name for object O</span>
<span class="kd">function</span> <span class="nf">"+"</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object_Safe_Pointer</span><span class="p">;</span>
<span class="c1">-- Allocate an object into the heap and return a safe pointer to it</span>
<span class="kd">function</span> <span class="nf">"-"</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object_Safe_Pointer</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Returns the object associated with the safe pointer</span>
<span class="kd">type</span> <span class="kt">Scalar</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">new</span> <span class="n">Object</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Scalar types are using a by-copy semantic</span>
<span class="kd">type</span> <span class="kt">Composite</span> <span class="kr">is</span> <span class="kr">abstract</span> <span class="kr">new</span> <span class="n">Object</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- Composite types are using a by-reference semantic for efficiency</span>
<span class="c1">-- reason. Not that these types are not thread safe.</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Composite</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object_Set</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Composite</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">--------------</span>
<span class="c1">-- Any Type --</span>
<span class="c1">--------------</span>
<span class="n">XML_Any_Type</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:anyType"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Any_Type</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Object</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">XML_Type</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Any_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Any_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Any_Type</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Any</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Any_Type</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Any_Type</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object_Access</span><span class="p">;</span>
<span class="c1">-----------</span>
<span class="c1">-- Array --</span>
<span class="c1">-----------</span>
<span class="no">XML_Array</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"soapenc:Array"</span><span class="p">;</span>
<span class="n">XML_Undefined</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:ur-type"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">SOAP_Array</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Composite</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Array</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Array</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">A</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Object_Set</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">SOAP_Array</span><span class="p">;</span>
<span class="c1">-- Type_Name of the array's elements, if not specified it will be computed</span>
<span class="c1">-- based on element's name.</span>
<span class="kd">function</span> <span class="nf">Size</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Array</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Natural</span><span class="p">;</span>
<span class="c1">-- Returns the number of item into the array</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Array</span><span class="p">;</span> <span class="nv">N</span> <span class="p">: </span><span class="nv">Positive</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Returns SOAP_Array item at position N</span>
<span class="c1">----------</span>
<span class="c1">-- Set --</span>
<span class="c1">----------</span>
<span class="kd">type</span> <span class="kt">SOAP_Set</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Composite</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="c1">-- A set is like an array but to record multi-occurence of parameters. The</span>
<span class="c1">-- SOAP message does not contain the enclosing SOAP array XML tag.</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Set</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Set</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">Set</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Object_Set</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">SOAP</span><span class="p">.</span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">SOAP</span><span class="p">.</span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">SOAP_Set</span><span class="p">;</span>
<span class="c1">-- Type_Name of the array's elements, if not specified it will be computed</span>
<span class="c1">-- based on element's name.</span>
<span class="c1">------------</span>
<span class="c1">-- Base64 --</span>
<span class="c1">------------</span>
<span class="n">XML_Base64</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"soapenc:base64"</span><span class="p">;</span>
<span class="n">XML_Base64_Binary</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:base64Binary"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">SOAP_Base64</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Base64</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">B64</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Base64</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">SOAP_Base64</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Base64</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-------------</span>
<span class="c1">-- Boolean --</span>
<span class="c1">-------------</span>
<span class="n">XML_Boolean</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:boolean"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Boolean</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">B</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Boolean</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Boolean</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Boolean</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Boolean</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">----------</span>
<span class="c1">-- Byte --</span>
<span class="c1">----------</span>
<span class="kd">type</span> <span class="kt">Byte</span> <span class="kr">is</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">2</span><span class="o">**</span><span class="mi">7</span> <span class="p">..</span> <span class="mi">2</span><span class="o">**</span><span class="mi">7</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
<span class="n">XML_Byte</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:byte"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Byte</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Byte</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">B</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Byte</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Byte</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Byte</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Byte</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Byte</span><span class="p">;</span>
<span class="c1">------------</span>
<span class="c1">-- Double --</span>
<span class="c1">------------</span>
<span class="n">XML_Double</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:double"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Double</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Double</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">D</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Long_Float</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Double</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Double</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Double</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Long_Float</span><span class="p">;</span>
<span class="c1">-----------</span>
<span class="c1">-- Float --</span>
<span class="c1">-----------</span>
<span class="n">XML_Float</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:float"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Float</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Float</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">F</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Float</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Float</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Float</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Float</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Float</span><span class="p">;</span>
<span class="c1">-------------</span>
<span class="c1">-- Integer --</span>
<span class="c1">-------------</span>
<span class="n">XML_Int</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:int"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Integer</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Integer</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">I</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Integer</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Int</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Integer</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Integer</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span><span class="p">;</span>
<span class="c1">----------</span>
<span class="c1">-- Long --</span>
<span class="c1">----------</span>
<span class="kd">type</span> <span class="kt">Long</span> <span class="kr">is</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">2</span><span class="o">**</span><span class="mi">63</span> <span class="p">..</span> <span class="mi">2</span><span class="o">**</span><span class="mi">63</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
<span class="n">XML_Long</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:long"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Long</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Long</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">L</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Long</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Long</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Long</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Long</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Long</span><span class="p">;</span>
<span class="c1">----------</span>
<span class="c1">-- Null --</span>
<span class="c1">----------</span>
<span class="no">XML_Null</span> <span class="p">:</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"1"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Null</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">XML_Type</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Null</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Null</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">N</span> <span class="p">(</span><span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">)</span> <span class="kr">return</span> <span class="n">XSD_Null</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Is_Empty</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Null</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">------------</span>
<span class="c1">-- Record --</span>
<span class="c1">------------</span>
<span class="kd">type</span> <span class="kt">SOAP_Record</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Composite</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Record</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Record</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">R</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Object_Set</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">""</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">SOAP_Record</span><span class="p">;</span>
<span class="c1">-- If Type_Name is omitted then the type name is the name of the record.</span>
<span class="c1">-- Type_Name must be specified for item into an array for example.</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Record</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Returns SOAP_Record field named Name</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Record</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object_Set</span><span class="p">;</span>
<span class="c1">-- Returns SOAP_Record fields named Name</span>
<span class="kd">function</span> <span class="nf">Exists</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Record</span><span class="p">;</span> <span class="nv">Field_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns True if the record O constains Field_Name</span>
<span class="c1">-----------</span>
<span class="c1">-- Short --</span>
<span class="c1">-----------</span>
<span class="kd">type</span> <span class="kt">Short</span> <span class="kr">is</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">2</span><span class="o">**</span><span class="mi">15</span> <span class="p">..</span> <span class="mi">2</span><span class="o">**</span><span class="mi">15</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span>
<span class="n">XML_Short</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:short"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Short</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Short</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">S</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Short</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Short</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Short</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Short</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Short</span><span class="p">;</span>
<span class="c1">------------</span>
<span class="c1">-- String --</span>
<span class="c1">------------</span>
<span class="n">XML_String</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:string"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_String</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">S</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_String</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">S</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_String</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_String</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-----------------</span>
<span class="c1">-- TimeInstant --</span>
<span class="c1">-----------------</span>
<span class="n">XML_Time_Instant</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:timeInstant"</span><span class="p">;</span>
<span class="n">XML_Date_Time</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:dateTime"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Time_Instant</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Time_Instant</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">subtype</span> <span class="kt">TZ</span> <span class="kr">is</span> <span class="kt">Integer</span> <span class="kr">range</span> <span class="o">-</span><span class="mi">11</span> <span class="p">..</span> <span class="o">+</span><span class="mi">11</span><span class="p">;</span>
<span class="no">GMT</span> <span class="p">:</span> <span class="kr">constant</span> <span class="n">TZ</span> <span class="p">:=</span> <span class="mi">0</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">T</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Calendar</span><span class="p">.</span><span class="nv">Time</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Time_Instant</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">;</span>
<span class="nv">Timezone</span> <span class="p">: </span><span class="nv">TZ</span> <span class="p">:=</span> <span class="nv">GMT</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Time_Instant</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Time_Instant</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="c1">-- Returns a GMT date and time</span>
<span class="c1">-------------------</span>
<span class="c1">-- Unsigned_Long --</span>
<span class="c1">-------------------</span>
<span class="kd">type</span> <span class="kt">Unsigned_Long</span> <span class="kr">is</span> <span class="ow">mod</span> <span class="mi">2</span><span class="o">**</span><span class="mi">64</span><span class="p">;</span>
<span class="n">XML_Unsigned_Long</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:unsignedLong"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Unsigned_Long</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Long</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">UL</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Unsigned_Long</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Unsigned_Long</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Unsigned_Long</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Long</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Long</span><span class="p">;</span>
<span class="c1">------------------</span>
<span class="c1">-- Unsigned_Int --</span>
<span class="c1">------------------</span>
<span class="kd">type</span> <span class="kt">Unsigned_Int</span> <span class="kr">is</span> <span class="ow">mod</span> <span class="mi">2</span><span class="o">**</span><span class="mi">32</span><span class="p">;</span>
<span class="n">XML_Unsigned_Int</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:unsignedInt"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Unsigned_Int</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Int</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">UI</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Unsigned_Int</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Unsigned_Int</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Unsigned_Int</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Int</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Int</span><span class="p">;</span>
<span class="c1">--------------------</span>
<span class="c1">-- Unsigned_Short --</span>
<span class="c1">--------------------</span>
<span class="kd">type</span> <span class="kt">Unsigned_Short</span> <span class="kr">is</span> <span class="ow">mod</span> <span class="mi">2</span><span class="o">**</span><span class="mi">16</span><span class="p">;</span>
<span class="n">XML_Unsigned_Short</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:unsignedShort"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Unsigned_Short</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Short</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">US</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Unsigned_Short</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Unsigned_Short</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Unsigned_Short</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Short</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Short</span><span class="p">;</span>
<span class="c1">-------------------</span>
<span class="c1">-- Unsigned_Byte --</span>
<span class="c1">-------------------</span>
<span class="kd">type</span> <span class="kt">Unsigned_Byte</span> <span class="kr">is</span> <span class="ow">mod</span> <span class="mi">2</span><span class="o">**</span><span class="mi">8</span><span class="p">;</span>
<span class="n">XML_Unsigned_Byte</span> <span class="p">:</span> <span class="kr">aliased</span> <span class="kr">constant</span> <span class="kt">String</span> <span class="p">:=</span> <span class="s">"xsd:unsignedByte"</span><span class="p">;</span>
<span class="kd">type</span> <span class="kt">XSD_Unsigned_Byte</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Byte</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">UB</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">Unsigned_Byte</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="nv">XML_Unsigned_Byte</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">XSD_Unsigned_Byte</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">XSD_Unsigned_Byte</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Byte</span><span class="p">;</span>
<span class="c1">-----------------</span>
<span class="c1">-- Enumeration --</span>
<span class="c1">-----------------</span>
<span class="kd">type</span> <span class="kt">SOAP_Enumeration</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Scalar</span> <span class="kr">with</span> <span class="kd">private</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">function</span> <span class="nf">Image</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Enumeration</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">XML_Image</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Enumeration</span><span class="p">;</span>
<span class="nv">Result</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Unbounded_String</span><span class="p">;</span>
<span class="nv">Encoding</span> <span class="p">: </span><span class="nv">Encoding_Style</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Encoded</span><span class="p">;</span>
<span class="nv">Schema</span> <span class="p">: </span><span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Definition</span> <span class="p">:=</span> <span class="nv">WSDL</span><span class="p">.</span><span class="nv">Schema</span><span class="p">.</span><span class="nv">Empty</span><span class="p">);</span>
<span class="kd">function</span> <span class="nf">E</span>
<span class="p">(</span><span class="nv">V</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Type_Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">;</span>
<span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span> <span class="p">:=</span> <span class="s">"item"</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span> <span class="p">:=</span> <span class="nv">Name_Space</span><span class="p">.</span><span class="nv">No_Name_Space</span><span class="p">)</span>
<span class="kr">return</span> <span class="n">SOAP_Enumeration</span><span class="p">;</span>
<span class="kd">function</span> <span class="nf">V</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">SOAP_Enumeration</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">---------</span>
<span class="c1">-- Get --</span>
<span class="c1">---------</span>
<span class="c1">-- It is possible to pass an XSD_Any_Type to all get routines below. The</span>
<span class="c1">-- proper value will be returned if the XSD_Any_Type is actually of this</span>
<span class="c1">-- type.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">XSD_Any_Type</span><span class="p">;</span>
<span class="c1">-- Returns O value as an XSD_Any_Type. Raises Data_Error if O is not a</span>
<span class="c1">-- SOAP anyType.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Long</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Long. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Long.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Integer</span><span class="p">;</span>
<span class="c1">-- Returns O value as an Integer. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Integer.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Short</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Short. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Short.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Byte</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Byte. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Byte.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Float</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Long_Float. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Float.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Long_Float</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Long_Long_Float. Raises Data_Error if O is not a</span>
<span class="c1">-- SOAP Double.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">String</span><span class="p">;</span>
<span class="c1">-- Returns O value as a String. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- String.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unbounded_String</span><span class="p">;</span>
<span class="c1">-- As above but returns an Unbounded_String</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="kt">Boolean</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Boolean. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Boolean.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Ada</span><span class="p">.</span><span class="n">Calendar</span><span class="p">.</span><span class="n">Time</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Time. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Time.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Long</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Unsigned_Long. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Unsigned_Long.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Int</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Unsigned_Byte. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Unsigned_Int.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Short</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Unsigned_Short. Raises Data_Error if O is not a</span>
<span class="c1">-- SOAP Unsigned_Short.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Unsigned_Byte</span><span class="p">;</span>
<span class="c1">-- Returns O value as a Unsigned_Byte. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Unsigned_Byte.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">SOAP_Base64</span><span class="p">;</span>
<span class="c1">-- Returns O value as a SOAP Base64. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Base64 object.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">SOAP_Record</span><span class="p">;</span>
<span class="c1">-- Returns O value as a SOAP Struct. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Struct.</span>
<span class="kd">function</span> <span class="nf">Get</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">SOAP_Array</span><span class="p">;</span>
<span class="c1">-- Returns O value as a SOAP Array. Raises Data_Error if O is not a SOAP</span>
<span class="c1">-- Array.</span>
<span class="c1">----------------</span>
<span class="c1">-- Name space --</span>
<span class="c1">----------------</span>
<span class="kd">procedure</span> <span class="nf">Set_Name_Space</span>
<span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="nv">NS</span> <span class="p">: </span><span class="nv">Name_Space</span><span class="p">.</span><span class="nv">Object</span><span class="p">);</span>
<span class="c1">-- Set the name space for object O</span>
<span class="kd">function</span> <span class="nf">Name_Space</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Name_Space</span><span class="p">.</span><span class="n">Object</span><span class="p">;</span>
<span class="c1">-- Returns name space associated with object O</span>
<span class="kd">procedure</span> <span class="nf">Rename</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">);</span>
<span class="c1">-- Set the name to the object</span>
<span class="kd">function</span> <span class="nf">Rename</span> <span class="p">(</span><span class="nv">O</span> <span class="p">: </span><span class="nv">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span> <span class="nv">Name</span> <span class="p">: </span><span class="nv">String</span><span class="p">)</span> <span class="kr">return</span> <span class="n">Object</span><span class="p">'</span><span class="na">Class</span><span class="p">;</span>
<span class="c1">-- Return the same object with changed name</span>
<span class="kd">private</span>
<span class="c1">-- implementation removed</span>
<span class="kr">end</span> <span class="nf">SOAP.Types</span><span class="p">;</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="rfc.html" title="12. References"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">AWS: Ada Web Server gpl-2017 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2002-2017, AdaCore.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
</div>
</body>
</html>
|