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
|
<section id="commands">
<title>Rivet Tcl Commands and Variables</title>
<section>
<para>
Starting with version 2.1.0 Rivet command set moved into the
<command>::rivet</command> namespace.
</para>
<para>
In order to preserve out of the box compatibility with existing scripts,
Rivet exports commands by default and makes them available for import
into any namespace (global namespace included).
Rivet's build system can be told not to export the command set by
passing the switch <command>--disable-rivet-commands-export</command>
to 'configure'. In the future we may change this option's default.
</para>
<para>
Commands must be imported into another namespace with the command:
</para>
<para>
<command>namespace import -force ::rivet::*</command>
</para>
<para>
Whenever a new application is being developed and compatibility
issues can be confined within specific files, it is recommended
that commands be specified with their fully qualified names.
</para>
</section>
<refentry id="shorthand">
<refnamediv>
<refname><?= ... ?></refname>
<refpurpose>
Shorthand construct for single strings output
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command><?= <arg choice="plain">$string</arg> ?></command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
This construct is a simplified form to print a single string wherever
needed in a <arg>.rvt</arg> template. The contruct is equivalent to
writing the following line of Tcl code
</para>
<programlisting>puts -nonewline $string</programlisting>
<para>
The <arg>string</arg> argument to the shorthand construct can
be any Tcl command returning a value
</para>
<para>
See <xref linkend="hello_world">Hello World</xref> or
<xref linkend="variable_access">Variable Access</xref>
</para>
</refsect1>
</refentry>
<refentry id="abort_code">
<refnamediv>
<refname>abort_code</refname>
<refpurpose>
Returns the code passed to <command>abort_page</command>
earlier during the request processing
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::abort_code</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Usage of this command is meaningful only in a script set as
AbortScript or AfterEveryScript.
<command>abort_code</command> returns the value of the optional
parameter passed to <command>abort_page</command> earlier in
the same request processing.
</para>
</refsect1>
</refentry>
<refentry id="abort_page">
<refnamediv>
<refname>abort_page</refname>
<refpurpose>
Stops outputting data to web page, similar in
purpose to PHP's <command>die</command> command.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::abort_page</command>
<group choice="req">
<arg><replaceable>abort code</replaceable></arg>
<arg><replaceable>-aborting</replaceable></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
This command flushes the output buffer and stops the Tcl
script from sending any more data to the client.
A normal Tcl script might use the
<command>exit</command> command, but that cannot be used in
Rivet without actually exiting the apache child
process!
<command>abort_page</command> triggers
the execution of an optional AbortScript that has to be
specified in the configuration. The value of the
argument <arg>abort code</arg> can be retrieved with the
<command>abort_code</command> command during the
execution of <link linkend="directives">AbortScript or
AfterEveryScript</link>,
allowing the script to take appropriate actions in order to deal
with the cause of the abort.
</para>
<para>
The argument <option>-aborting</option> causes <option>abort_page</option>
to return 1 when the current execution is the outcome of an abort condition.
In other words this query is meaningful in code specified as
<link linkend="directives">AfterEveryScript</link> to understand
if an abort condition took place beforehand.
</para>
</refsect1>
</refentry>
<refentry id="apache_log_error">
<refnamediv>
<refname>apache_log_error</refname>
<refpurpose>log messages to the Apache error log</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::apache_log_error</command>
<arg>priority</arg>
<arg>message</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The apache_log_error command logs a message to the
Apache error log, whose name and location have been
set by the <option>ErrorLog</option> directive.
</para>
<para>
Priority must be one of
<option>debug</option>,
<option>info</option>,
<option>notice</option>,
<option>warning</option>,
<option>err</option>,
<option>crit</option>,
<option>alert</option>, or
<option>emerg</option>.
</para>
</refsect1>
</refentry>
<refentry id="apache_table">
<refnamediv>
<refname>apache_table</refname>
<refpurpose>access and manipulate Apache tables in the request structure.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<group choice="req">
<arg>get</arg>
<arg>set</arg>
<arg>exists</arg>
<arg>unset</arg>
<arg>names</arg>
<arg>array_get</arg>
<arg>clear</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The apache_table command is for accessing and manipulating
Apache tables in the request structure.
</para>
<para>
The table name must be one of
<option>notes</option>,
<option>headers_in</option>,
<option>headers_out</option>,
<option>err_headers_out</option>, or
<option>subprocess_env</option>.
</para>
<variablelist>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">get</arg>
<arg><replaceable>tablename</replaceable></arg>
<arg><replaceable>key</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
When given the name of an Apache table
<option><replaceable>tablename</replaceable></option>
and the name of a key
<option><replaceable>tablename</replaceable></option>,
returns the value of the key in the table, or an empty
string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">set</arg>
<arg><replaceable>tablename</replaceable></arg>
<arg><replaceable>key</replaceable></arg>
<arg><replaceable>value</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">set</arg>
<arg><replaceable>tablename</replaceable></arg>
<arg><replaceable>list</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Stores the <option><replaceable>value</replaceable></option> in
the table <option><replaceable>tablename</replaceable></option>
under the key <option><replaceable>key</replaceable></option>.
</para>
<para>
For the list form,
<option><replaceable>list</replaceable></option> contains
a list of zero or more pairs of key-value pairs to be
set into the table
<option><replaceable>tablename</replaceable></option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">exists</arg>
<arg><replaceable>tablename</replaceable></arg>
<arg><replaceable>key</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns 1 if the specified key,
<option><replaceable>key</replaceable></option>,
exists in table
<option><replaceable>tablename</replaceable></option>,
else 0.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">unset</arg>
<arg><replaceable>tablename</replaceable></arg>
<arg><replaceable>key</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Removes the key-value pair referenced by
<option><replaceable>key</replaceable></option>
from the table
<option><replaceable>tablename</replaceable></option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">names</arg>
<arg><replaceable>tablename</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns a list of all of the keys present in the table
<option><replaceable>tablename</replaceable></option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">array_get</arg>
<arg><replaceable>tablename</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns a list of key-value pairs from the table
<option><replaceable>tablename</replaceable></option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::apache_table</command>
<arg choice="plain">clear</arg>
<arg><replaceable>tablename</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Clears the contents of the specified table.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<refentry id="catch">
<refnamediv>
<refname>catch</refname>
<refpurpose>wraps core command <command>catch</command> and handles in
a special way fake error conditions resulting from calls to <command>exit</command>
and <command>abort_page</command></refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::catch</command>
<arg><replaceable>script</replaceable></arg>
<arg><replaceable>error_code_var_name</replaceable></arg>
<arg><replaceable>options_var_name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>::rivet::catch</command> wraps the core language's same command adding some
extra error handling needed by mod_rivet design.
The rationale for Rivet to have its own <command>::rivet::catch</command> reads as follows:
within mod_rivet a script execution can be interrupted by either calling
<command>::rivet::exit</command>(deprecated) or <command>::rivet::abort_page</command>. These commands
implement a simple internal exception mechanism by
returning a special error code so that execution is in turn handed down to the
<command>AbortScript</command> and eventually to <command>AfterEveryScript</command> (if any of them is
defined). Any code calling one of these commands which runs under control of the
<command>::catch</command> command would need to do this chore itself, checking the error info and in case
throw the error again if it had been originated by one of mod_rivet's exceptions calls.
This is what <command>::rivet::catch</command> does hiding the implementation
details to provide a better and more compatibile way to handle this condition.
</para>
<note>
This command is not meant to replace the core command, thus it's not exported from the
<command>::rivet</command> namespace and therefore has to be fully qualified.
</note>
</refsect1>
</refentry>
<!-- Reference page for command 'clock_to_rfc' -->
<refentry id="clock_to_rfc">
<refnamediv>
<refname>clock_to_rfc850_gmt</refname>
<refpurpose>create a rfc850 time from [clock seconds].</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::clock_to_rfc850_gmt</command>
<arg><replaceable>seconds</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Convert an integer-seconds-since-1970 click value to
RFC850 format, with the additional requirement that it be
GMT only.
</para>
</refsect1>
</refentry>
<!-- Reference page for command 'cookie' -->
<refentry id="cookie">
<refnamediv>
<refname>cookie</refname>
<refpurpose>get, set and delete cookies.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::cookie</command>
<arg>set</arg>
<arg><replaceable>cookieName</replaceable></arg>
<arg><replaceable><optional>cookiValue</optional></replaceable></arg>
<arg>-days <replaceable>expireInDays</replaceable></arg>
<arg>-hours <replaceable>expireInHours</replaceable></arg>
<arg>-minutes <replaceable>expireInMinutes</replaceable></arg>
<arg>-expires <replaceable>Wdy, DD-Mon-YYYY HH:MM:SS GMT</replaceable></arg>
<arg>-path <replaceable>uriPathCookieAppliesTo</replaceable></arg>
<arg>-secure <replaceable>1/0</replaceable></arg>
<arg>-HttpOnly <replaceable>1/0</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>::rivet::cookie</command>
<arg>get</arg>
<arg><replaceable>cookieName</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>::rivet::cookie</command>
<arg>delete</arg>
<arg><replaceable>cookieName</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>::rivet::cookie</command>
<arg>unset</arg>
<arg><replaceable>cookieName</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>cookie</command> gets, sets, unsets or deletes a cookie. When you
get a cookie, the command returns the value of the cookie,
or an empty string if no cookie exists.
</para>
<para>
<command>cookie delete</command> will set the timeout value to -1 minutes -
deleting the cookie in the browser.
</para>
<para>
<command>cookie unset</command> will remove the defined cookie in the server
(perhaps preparatory to checking/resetting the cookie).
</para>
<para>
The command has a number of switches setting a cookie attributes
</para>
</refsect1>
</refentry>
<refentry id="debug">
<refnamediv>
<refname>debug</refname>
<refpurpose>
A command to print strings, arrays
and the values of variables as specified by the arguments.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::debug</command>
<arg choice="plain">-subst</arg><arg><on|off></arg>
<arg choice="plain">-separator</arg><arg><string></arg>
<arg choice="plain">-option</arg><arg><replaceable><value></replaceable></arg>
<arg choice="plain">-option</arg><arg><replaceable><value></replaceable></arg>
<arg choice="plain">...</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
A command to make debugging more convenient print strings, arrays
and the values of variables as specified by the arguments.
</para>
<para>
Also allows the setting of an array called debug which will pick up
options for all debug commands.
</para>
</refsect1>
</refentry>
<refentry id="env">
<refnamediv>
<refname>env</refname>
<refpurpose>
Loads a single "environmental variable" into a Tcl variable.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::env</command>
<arg><replaceable>varName</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
If it is only necessary to load one environmental variable,
this command may be used to avoid the overhead of loading
and storing the entire array.
</para>
</refsect1>
</refentry>
<refentry id="escape_sgml_chars">
<refnamediv>
<refname>escape_sgml_chars</refname>
<refpurpose>escape special SGML characters in a string.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::escape_sgml_chars</command>
<arg>string</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Scans through each character in the specified string looking
for any special (with respect to SGML, and hence HTML) characters
from the specified string, and returns the result.
For example, the right angle bracket is escaped to the corrected
ampersand gt symbol.
</para>
<!--note>
You must require the <command>rivetlib</command> package in order to gain access to this command
</note -->
</refsect1>
</refentry>
<refentry id="escape_shell_command">
<refnamediv>
<refname>escape_shell_command</refname>
<refpurpose>escape shell metacharacters in a string.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::escape_shell_command</command>
<arg>string</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Scans through each character in the specified string looking
for any shell metacharacters, such as asterisk, less than and
greater than, parens, square brackets, curly brackets, angle
brackets, dollar signs, backslashes, semicolons, ampersands,
vertical bars, etc.
</para>
<para>
For each metacharacter found, it is quoted in the result by
prepending it with a backslash, returning the result.
</para>
<!-- note>
You must require the <command>rivetlib</command> package in order to gain access to this command
</note -->
</refsect1>
</refentry>
<refentry id="escape_string">
<refnamediv>
<refname>escape_string</refname>
<refpurpose>convert a string into escaped characters.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::escape_string</command>
<arg>string</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Scans through each character in the specified string looking
for special characters, escaping them as needed, mapping
special characters to a quoted hexadecimal equivalent,
returning the result.
</para>
<para>
This is useful for quoting strings that are going to be
part of a URL.
</para>
<!-- note>
You must require the <command>rivetlib</command> package in order to gain access
to this command
</note -->
</refsect1>
</refentry>
<refentry id="exit">
<refnamediv>
<refname>exit</refname>
<refpurpose>terminate execution and child process</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::exit</command>
<arg>code</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Replaces Tcl's <command>exit</command> core command. <command>::rivet::exit</command>
interrupts execution of the current script and passes execution to AbortScript if
such script is set. After AbortScript has finished and request processing completed
the child process is forced to exit by calling Tcl_Exit producing the same final
effect of the core command. During an <command>AbortScript</command> execution the
exit condition can be detected
<programlisting>if {[<command>::rivet::abort_page -exiting</command>]} {
...handle exit condition
}</programlisting>
</para>
<para>
<command>::rivet::exit</command> has a single optional argument <arg>code</arg>. This
value must be a positive integer number to be passed to Tcl_Exit. If any other value is
given <arg>code</arg> is set to 0. The exit code can be obtained from the dictionary
returned by <command>::rivet::abort_code</command>
</para>
<programlisting>[::rivet::abort_code]
<== return_code <arg>code</arg> error_code exit</programlisting>
<para>
We support this command in order to have a gentle way to terminate a request processing
before actually exit the child process and avoid an abrupt interruption of a request that
might leave an application in a inconsistent state. In some cases <command>::rivet::exit</command>
could be the only way to exit a process and force the Apache HTTP web server to start
a fresh one. Moreover the core <command>exit</command> could be called from third parties
software and you may not be aware of it. We thus decided to trap this command and give it
the most gentle behavior still preserving the its basic purpose.
</para>
<note>
Nonetheless we discourage the programmer to use such command, and suggest to focus on proper
application design and avoid such a drastic way to bail out.
If you need to restart the child processes from time to time we recommend to check the
MaxRequests parameter in the
<ulink url="https://httpd.apache.org/docs/2.4/mod/prefork.html">prefork MPM documentation</ulink>
</note>
</refsect1>
</refentry>
<refentry id="headers">
<refnamediv>
<refname>headers</refname>
<refpurpose>set and parse HTTP headers.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::headers</command>
<group choice="req">
<arg>get</arg>
<arg>set</arg>
<arg>redirect</arg>
<arg>add</arg>
<arg>type</arg>
<arg>numeric</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>headers</command> command is for setting and
parsing HTTP headers.
</para>
<variablelist>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">get</arg>
<arg><replaceable>headername</replaceable></arg>
<arg><replaceable>value</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Read arbitrary header names and values from output HTTP headers
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">set</arg>
<arg><replaceable>headername</replaceable></arg>
<arg><replaceable>value</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Set arbitrary header names and values into output HTTP headers
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">sent</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Test internal status of the module and returns 1
if the HTTP headers have been already sent
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">redirect</arg>
<arg><replaceable>uri</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Redirect from the current page to a new
URI. <emphasis>Must</emphasis> be done in the first block
of TCL code.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">add</arg>
<arg><replaceable>headername</replaceable></arg>
<arg><replaceable>value</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>Add text to header
<varname>headername</varname>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">type</arg>
<arg><replaceable>content-type</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
This command sets the <constant>Content-type</constant>
header returned by the script, which is useful if you wish
to send content other than HTML with Rivet - PNG or jpeg
images, for example.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::headers</command>
<arg choice="plain">numeric</arg>
<arg><replaceable>response code</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Set a numeric response code, such as 200, 404 or 500.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<refentry id="html">
<refnamediv>
<refname>html</refname>
<refpurpose>construct html tagged text.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::html</command>
<arg><replaceable>string</replaceable></arg>
<arg rep="repeat"><replaceable>arg</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Print text with the added ability to pass HTML tags
following the string. Example:
<programlisting>::rivet::html "Test" b i</programlisting>
produces: <computeroutput><b><i>Test</i></b></computeroutput>
</para>
</refsect1>
</refentry>
<refentry id="http_accept">
<refnamediv>
<refname>http_accept</refname>
<refpurpose>Parse HTTP Accept header lines</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::http_accept
<arg><replaceable>-zeroweight</replaceable></arg>
<arg><replaceable>-default</replaceable></arg>
<arg><replaceable>-list</replaceable></arg>
http_accept_line</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Command for parsing HTTP Accept header lines that tell the
server about preferences and/or capabilities of the browser
(e.g. content language,media type, etc.). The following
script
</para>
<para>
<command>::rivet::http_accept</command> returns a dictionary
value in which every content preference is matched to its
precedence value
</para>
<programlisting>load_headers
set language_precedence [::rivet::http_accept $headers(Accept-Language)]
foreach lan [dict keys $language_precedence] {
puts "$lan -> [dict get $language_precedence $lan]"
}</programlisting>
<para>
when run from a browser where 5 languages were chosen
would output
</para>
<programlisting>en-us -> 1
en -> 0.8
it -> 0.6
de-de -> 0.4
fr-fr -> 0.2</programlisting>
<para>
The <replaceable>-list</replaceable> switch would suppress
the precedence values and the accepted fields
are returned listed with decreasing precedence order.
</para>
<programlisting> puts [::rivet::http_accept -list $headers(Accept-Language)]
text/html application/xhtml+xml application/xml */*
</programlisting>
<para>
</para>
</refsect1>
</refentry>
<refentry id="import_keyvalue_pairs">
<refnamediv>
<refname>import_keyvalue_pairs</refname>
<refpurpose>Import an argument list into the named array</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::import_keyvalue_pairs</command>
<arg>arrayName</arg>
<arg>argsList</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
key-value pairs, like "-foo bar" are stored in the array <arg>arrayName</arg>.
In that case, the value "bar" would be stored in the element "foo"
</para>
<para>
If "--" appears or a key doesn't begin with "-", the rest of the arg
list is stored in the special args element of the array.
</para>
<para>
Example:
<programlisting>::rivet::import_keyvalue_pairs keyvalue_map [list -a1 v1 -a2 v2 -a3 v3 -- 1 2 3 4 5]
parray keyvalue_map
keyvalue_map(a1) = v1
keyvalue_map(a2) = v2
keyvalue_map(a3) = v3
keyvalue_map(args) = 1 2 3 4 5</programlisting>
</para>
</refsect1>
</refentry>
<refentry id="include">
<refnamediv>
<refname>include</refname>
<refpurpose>includes a file into the output stream without modification.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::include</command>
<arg><replaceable>filename_name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Include a file without parsing it for processing tags <?
and ?>. This is the best way to include an HTML file or
any other static content.
</para>
</refsect1>
</refentry>
<refentry id="incr0">
<refnamediv>
<refname>incr0</refname>
<refpurpose>increment a variable or set it to 1 if nonexistent.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>incr0</command>
<arg><replaceable>varname</replaceable></arg>
<arg><replaceable>num</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Increment a variable
<option><replaceable>varname</replaceable></option> by
<option><replaceable>num</replaceable></option>. If the
variable doesn't exist, create it instead of returning an
error.
</para>
<note>
incr0 functionality is provided by the native <command>incr</command> in
Tcl >= 8.5, therefore this command is deprecated and kept as an
interpreter alias only for compatibility. As such <command>incr0</command>
wasn't moved to the ::rivet namespace and
it will be removed in future versions of Rivet.
</note>
</refsect1>
</refentry>
<refentry id="inspect">
<refnamediv>
<refname>inspect</refname>
<refpurpose>Introspection command for Rivet configuration</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::inspect</command>
<arg><replaceable>configuration_section</replaceable></arg>
<arg><replaceable>configuration_parameter</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>::rivet::inspect</command> provides introspection into the running
configuration of Rivet. Rivet's debug command uses it in order to gain insight
into the configuration, but it can be used in any script.
</para>
<para>
<command>::rivet::inspect</command> can be called in 5 different forms
</para>
<itemizedlist mark="square">
<listitem>
With no argument the command returns a dictionary with 3
keys: server, dir, user. Each key is associated to a subdictionary
carrying the configuration as set for that request. In this form the command is
meant to support compatibility with previous versions of mod_rivet
where three global arrays were created to be internally used by command
<command>::rivet::debug</command>.
</listitem>
<listitem>
With the <arg>-all</arg> argument a dictionary
carrying the whole configuration for that specific request is returned.
If a configuration parameter is not set it's given the
string <emphasis>undefined</emphasis>. Returned configuration paramenters
are<programlisting> "ServerInitScript",
"GlobalInitScript",
"ChildInitScript",
"ChildExitScript",
"BeforeScript",
"AfterScript",
"AfterEveryScript",
"AbortScript",
"ErrorScript",
"UploadMaxSize",
"UploadDirectory",
"UploadFilesToVar",
"SeparateVirtualInterps",
"HonorHeaderOnlyRequests"</programlisting>
</listitem>
<listitem>
With one of the Rivet configuration directives listed above as
single argument <command>::rivet::inspect</command> returns the
current value in the configuration record.
</listitem>
<listitem>
Passing the argument "script" <command>::rivet::inspect</command>
returns a path to the current script in a similar way
core command <command>[info script]</command> does. The basic
difference is that the core command returns a relative path with
respect to the current working directory, whereas mod_rivet's command
returns the full path.
</listitem>
<listitem>
Passing the argument "server" <command>::rivet::inspect</command>
returns a dictionary with these fields taken from the server record
descriptor
<itemizedlist>
<listitem>hostname: The server hostname </listitem>
<listitem>admin: The admin's contact information</listitem>
<listitem>errorlog: The name of the error log</listitem>
<listitem>server_path: Pathname for ServerPath</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</refsect1>
</refentry>
<!-- refentry id="lassign">
<refnamediv>
<refname>lassign</refname>
<refpurpose>Assign a list of values to a list of variables</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::lassign</command>
<arg>value_list</arg>
<arg>variables</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>lassign</command> emulates the TclX lassign command. It accepts
a list variables and treats the rest as a list of variable names that will
be assigned with the values in the caller's scope
</para>
<para>
<programlisting># ::rivet::lassign {1 2 3} a b c
# set a
1
# set b
2
# set c
3</programlisting>
</para>
</refsect1>
</refentry -->
<refentry id="lassign_array">
<refnamediv>
<refname>lassign_array</refname>
<refpurpose>Assign a list of values to array variables</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::lassign_array</command>
<arg>value_list</arg>
<arg>array_name</arg>
<arg>array_variables</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>lassign_array</command> is an utility command inspired by the same Tclx command and
with a close resemblance with Tcl's <command>lassign</command> for assigning list elements to variables.
<command>lassign_array</command> first argument is a list of values to be assigned to an array that must be
given as second argument. The remaining arguments are the array's variable names which will store
as values the elements of the list. Variables names don't matching values in the list are given an empty string.
Unassigned list elements are returned as a list.
</para>
<programlisting>::rivet::lassign_array {1 2 3 4} assigned_array a b c d
parray assigned_array
<emphasis role="strong">assigned_array</emphasis>
assigned_array(a) = 1
assigned_array(b) = 2
assigned_array(c) = 3
assigned_array(d) = 4
set rem [::rivet::lassign_array {1 2 3 4 5 6 7} assigned_array a b c d]
puts $rem
5 6 7</programlisting>
</refsect1>
</refentry>
<refentry id="lempty">
<refnamediv>
<refname>lempty</refname>
<refpurpose>
Returns 1 if <list> is empty or 0 if it has any elements.
This command emulates the TclX lempty command.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::lempty</command>
<arg choice="plain">list</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Returns 1 if <list> is empty or 0 if it has any elements.
This command emulates the TclX lempty command.
</para>
</refsect1>
</refentry>
<refentry id="lmatch">
<refnamediv>
<refname>lmatch</refname>
<refpurpose>
Look for elements in <list> that match <pattern>
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::lmatch</command>
<group choice="req">
<arg>-exact</arg>
<arg>-glob</arg>
<arg>-regexp</arg>
</group>
<arg choice="plain">list</arg>
<arg choice="plain">pattern</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Look for elements in <list> that match <pattern>.
This command is a decent replacement for TclX lmatch command when TclX is
not available
</para>
<para>
In the following example a regular expression is matched against
each element in the input list and a list containing the matching
elements is returned
</para>
<para>
<programlisting>::rivet::lmatch -regexp { aaxa bxxb ccxxxxcc } {.+[x]{2}.+}
bxxb ccxxxxcc</programlisting>
</para>
</refsect1>
</refentry>
<refentry id="load_cookies">
<refnamediv>
<refname>load_cookies</refname>
<refpurpose>get any cookie variables sent by the client.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::load_cookies</command>
<arg choice="opt"><replaceable>array_name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
</refsect1>
<para>
Load the array of cookie variables into the specified
array name. Uses array <option>cookies</option> by
default.
</para>
</refentry>
<refentry id="load_env">
<refnamediv>
<refname>load_env</refname>
<refpurpose>get the request's environment variables.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::load_env</command>
<arg choice="opt"><replaceable>array_name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Load the array of environment variables into the specified
array name. Uses array <option>::request::env</option> by
default.
</para>
<para>
As Rivet pages are run in the <option>::request</option>
namespace, it isn't necessary to qualify the array name
for most uses - it's ok to access it as
<option>env</option>.
</para>
</refsect1>
</refentry>
<refentry id="load_headers">
<refnamediv>
<refname>load_headers</refname>
<refpurpose>get client request's headers.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::load_headers</command>
<arg><replaceable>array_name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Load the headers that come from a client request into the
provided array name, or use <option>headers</option> if no
name is provided.
</para>
</refsect1>
</refentry>
<refentry id="load_response">
<refnamediv>
<refname>load_response</refname>
<refpurpose>load form variables into an array.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::load_response</command>
<arg><replaceable>arrayName</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Load any form variables passed to this page into an
array. If <command>load_response</command> is called without
arguments the array <option>response</option> is created in
the scope of the caller. If the variables var1,var2,var3...
having values val1,val2,val3... are passed to the page, the
resulting array will be a collection mapping var1,var2,var3...
to their corresponding values. <command>load_response</command>
was inspired by the same NeoWebScript procedure in the way
it deals with multiple assignments: if a variable
is assigned more than once the corresponding array element will be a
list of the values for the variable. This can be useful in the case
of forms with checkbox options that are given the same name.
This condition is signalled by the presence of an auxiliary array
variable.
</para>
<para>
Example: if a group of checkboxes are associated to the <option>var1</option>
variable then <command>response(var1)</command> will store
the list of their values and the array will also have the extra variable
<option>response(__var1)</option> which can be tested with
the usual <command>[info exists response(<option>__var1</option>)]</command>
</para>
<para>
Calling <command>load_response</command> several times for the same
array results in adding more values to the array at every call.
When needed it is left to the caller to empty the array between
two subsequent calls.
</para>
</refsect1>
</refentry>
<refentry id="lremove">
<refnamediv>
<refname>lremove</refname>
<refpurpose>remove from a list elements matching one or more patterns</refpurpose>
</refnamediv>
<refsynopsisdiv>
<command>::rivet::lremove</command>
<group choice="req">
<arg>-regexp | -glob | -exact</arg></group>
<arg choice="plain">list</arg>
<arg choice="plain">pattern</arg>
<arg><replaceable>pattern</replaceable></arg>
<arg><replaceable>pattern</replaceable></arg>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>lremove</command> removes from list <arg>list</arg> the first occurrence
of an element matching one of the patterns listed in the command line. By specifying the
<option>-all</option> option every occurrence of one the patterns is removed
</para>
<para>
Pattern matching can be <option>-exact</option>,<option>-glob</option> style or following
regular expressions (<option>-regexp</option>). These options are globally valid across the
whole pattern list (default is glob style matching)
</para>
<programlisting>::rivet::lremove -all -regexp {aa e111 bab aa} aa e111 bab
e111 bab
::rivet::lremove -all -regexp {aa e111 bab aa} aa "e\\d+"
bab</programlisting>
</refsect1>
</refentry>
<refentry id="makeurl">
<refnamediv>
<refname>makeurl</refname>
<refpurpose>construct url's based on hostname, port.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::makeurl</command>
<arg><replaceable>filename</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Create a self referencing URL from a filename. <command>makeurl</command>
can be used in three ways
<itemizedlist>
<listitem> No argument is passed to the command (returns the current script URL)</listitem>
<listitem>
A relative style path is passed (returns the argument prepended with the
current script's URL
</listitem>
<listitem>
An absolute path is passed to the command: (returns the full URL to the
resource)
</listitem>
</itemizedlist>
</para>
<para>
Example of absolute path: <programlisting>::rivet::makeurl /tclp.gif</programlisting> returns
<computeroutput>http://[hostname]:[port]/tclp.gif</computeroutput>.
where hostname and port are the hostname and port of the
server in question. The protocol prefix is inferred from the protocol in the URL referencing the
script.
</para>
</refsect1>
</refentry>
<refentry id="no_body">
<refnamediv>
<refname>no_body</refname>
<refpurpose>Prevents Rivet from sending any content.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::no_body</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
This command is useful for situations where it is necessary
to only return HTTP headers and no actual content. For
instance, when returning a 304 redirect.
</para>
</refsect1>
</refentry>
<refentry id="parray">
<refnamediv>
<refname>parray</refname>
<refpurpose>Tcl's <command>parray</command> with html formatting.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::parray</command>
<arg><replaceable>arrayName</replaceable></arg>
<arg><replaceable><optional>pattern</optional></replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
An html version of the standard Tcl
<command>parray</command> command. Displays the entire
contents of an array in a sorted, nicely-formatted way.
Mostly used for debugging purposes.
</para>
</refsect1>
</refentry>
<refentry id="parse">
<refnamediv>
<refname>parse</refname>
<refpurpose>parses a Rivet template file.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::parse</command>
<arg><replaceable>filename</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Like the Tcl <command>source</command> command, but also
parses for Rivet <? and ?> processing tags. Using
this command, you can use one .rvt file from another.
</para>
</refsect1>
</refentry>
<refentry id="raw_post">
<refnamediv>
<refname>raw_post</refname>
<refpurpose>get the unmodified body of a POST request sent by the client.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::raw_post</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
</refsect1>
<para>
Returns the raw POST data from the request. If the request was
not a POST or there is no data, then "" - an empty string - is returned.
</para>
</refentry>
<refentry id="redirect">
<refnamediv>
<refname>redirect</refname>
<refpurpose>Interrupt processing and divert to a new URL</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::redirect</command>
<arg>URL</arg>
<arg>permanent (default: 0)</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>::rivet::redirect</command> diverts the browser to a new URL and marks
the redirection as either permanent in the browser local cache or
non permanent (default).
Calling <command>::rivet::redirect</command> causes the script execution to interrupt
and control passes to <command>AbortScript</command>, if such script is
set, by calling <command>::rivet::abort_page</command> and passing as abort
code a dictionary with 2 keys:
<itemizedlist>
<listitem><command>error_code</command>: string literal 'redirect'</listitem>
<listitem><command>location</command>: the URL the browser will be redirected to</listitem>
</itemizedlist>
</para>
<para>
<command>::rivet::redirect</command> drives the redirection by setting the
301 (permanent redirect) or 302 (non permanent redirect) HTTP status codes and
attempts to discard the output the script might have already placed in the
stdout channel buffer. Therefore the command can fail if
<itemizedlist>
<listitem>A <command>flush stdout</command> was called before <command>::rivet::redirect</command>
thus causing the HTTP headers to be sent and preventing any possibility to
manipulate them</listitem>
<listitem>The channel buffer was filled causing Tcl to
flush the channel</listitem>
</itemizedlist>
The <command>stdout</command> channel, like any Tcl channels, can be manipulated
and if needed its internal buffer streched.
</para>
</refsect1>
</refentry>
<refentry id="read_file">
<refnamediv>
<refname>read_file</refname>
<refpurpose>
Read the entire contents of a file and return it as a string.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::read_file</command>
<arg>file name</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
This is a utility command which loads the entire content of
a file and returns it as a result.
</para>
</refsect1>
</refentry>
<refentry id="try">
<refnamediv>
<refname>try</refname>
<refpurpose>
Catch error and exception conditions
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::try</command>
<arg>script</arg>
<arg>script</arg>
<arg><replaceable>handlers</replaceable></arg>
<arg><replaceable>finally script</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>::rivet::try</command> wraps the core language
command and simply traps exceptions that might have raised
by <command>::rivet::abort_page</command> and
<command>::rivet::exit</command> to throw them again and
thus causing <command>AbortScript</command> to be executed.
</para>
<para>
If neither <command>::rivet::abort_page</command> nor
<command>::rivet::exit</command> are called from <arg>script</arg>
then any handlers specified in the command are tested for execution.
Thus <command>::rivet::try</command> can transparently be used
as a replacement for Tcl's own <command>try</command> and it's needed
if you want <arg>script</arg> to safely bail out to <command>AbortScript</command>
</para>
<para>
This script shows how <command>::rivet:try</command>
handles different exceptions or errors. You can drive this script
within mod_rivet adding the arguments fail or abort or exit to its URL.
You can handle the <quote>exit</quote> and <quote>abort</quote> cases with
an <command>AbortScript</command>.
See <xref linkend="directives"><command>AbortScript</command></xref>
</para>
<programlisting><html><?::rivet::try {
if {[::rivet::var_qs exists exit]} {
::rivet::exit 100
} elseif {[::rivet::var_qs exists abort]} {
::rivet::abort_page
} elseif {[::rivet::var_qs exists fail]} {
# this is just a non existent command
wrong_command
} else {
puts "<b>OK</b>"
}
} on error {e o} {
puts "catching error -&gt; $e<br/>"
dict for {fd fv} $o {
puts "$fd --&gt;&gt; $fv<br/>"
}
}
?></html></programlisting>
<para>
Placing this code in a file (try.rvt) on the
web server <emphasis>DocumentRoot</emphasis>
directory and setting for example the browser
to <command>http://localhost/try.rvt?fail=1</command>.
</para>
<programlisting>catching error -> invalid command name "wrong_command"
-errorcode -->> TCL LOOKUP COMMAND wrong_command
-code -->> 1
-level -->> 0
-errorstack -->> INNER {invokeStk1 wrong_command} UP 1
-errorinfo -->> invalid command name "wrong_command" while executing "wrong_command" ("::try" body line 9)
-errorline -->> 9</programlisting>
</refsect1>
</refentry>
<refentry id="unescape_string">
<refnamediv>
<refname>unescape_string</refname>
<refpurpose>unescape escaped characters in a string.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::unescape_string</command>
<arg>string</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Scans through each character in the specified string looking
for escaped character sequences (characters containing a
percent sign and two hexadecimal characters, unescaping them
back to their original character values, as needed, also mapping
plus signs to spaces, and returning the result.
</para>
<para>
This is useful for unquoting strings that have been quoted to
be part of a URL.
</para>
<!-- note>
You must require the <command>rivetlib</command> package in order to gain
access to this command
</note -->
</refsect1>
</refentry>
<refentry id="upload">
<refnamediv>
<refname>upload</refname>
<refpurpose>handle a file uploaded by a client.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::upload</command>
<group choice="req">
<arg>channel</arg>
<arg>save</arg>
<arg>data</arg>
<arg>exists</arg>
<arg>size</arg>
<arg>type</arg>
<arg>filename</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The upload command is for file upload manipulation.
See the relevant Apache Directives to further configure the
behavior of this Rivet feature.
</para>
<variablelist>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">channel</arg>
<arg><replaceable>uploadname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
When given the name of a file upload
<option><replaceable>uploadname</replaceable></option>,
returns a Tcl channel that can be used to access the
uploaded file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">save</arg>
<arg><replaceable>uploadname</replaceable></arg>
<arg><replaceable>filename</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Saves the <option><replaceable>uploadname</replaceable></option> in
the file <option><replaceable>filename</replaceable></option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">data</arg>
<arg><replaceable>uploadname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns data uploaded to the server. This is binary clean
- in other words, it will work even with files like
images, executables, compressed files, and so on.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">exists</arg>
<arg><replaceable>uploadname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns true if an upload named <arg>uploadname</arg>
exists. This can be used in scripts that are meant to
be run by different forms that send over uploads that
might need specific processing.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">size</arg>
<arg><replaceable>uploadname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the size of the file uploaded.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">type</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
If the <varname>Content-type</varname> is set, it is
returned, otherwise, an empty string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">filename</arg>
<arg><replaceable>uploadname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the filename on the remote host that uploaded the file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">tempname</arg>
<arg><replaceable>uploadname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the name of the temporary file on the local host that the file was uploaded into.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::upload</command>
<arg choice="plain">names</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the variable names, as a list, of all the files uploaded.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
See <xref linkend="file_upload"/>.
</para>
</refsect1>
</refentry>
<refentry id="url_query">
<refnamediv>
<refname>url_query</refname>
<refpurpose>builds a URL query from parameter-value pairs</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::url_query</command>
<arg>par1 value1 par2 value2 ...</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Builds a URL query out of a list of parameter-value pairs. If
the argument list has an odd length the last element is silently
discarded. The values of each pair in the list are passed through
<command>::rivet::escape_string</command> for proper representation
of characters that could break the URL syntax
</para>
<programlisting>set query [::rivet::url_query par1 val1 par2 val2 par3 val3]
puts $query
par1=val1&par2=val2&par3=val3</programlisting>
</refsect1>
</refentry>
<refentry id="var">
<refnamediv>
<refname>var</refname>
<refname>var_qs</refname>
<refname>var_post</refname>
<refpurpose>get the value of a form variable.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::var</command>
<group choice="req">
<arg>get</arg>
<arg>list</arg>
<arg>exists</arg>
<arg>number</arg>
<arg>all</arg>
</group>
</cmdsynopsis>
<cmdsynopsis>
<command>::rivet::var_qs</command>
<group choice="req">
<arg>get</arg>
<arg>list</arg>
<arg>exists</arg>
<arg>number</arg>
<arg>all</arg>
</group>
</cmdsynopsis>
<cmdsynopsis>
<command>::rivet::var_post</command>
<group choice="req">
<arg>get</arg>
<arg>list</arg>
<arg>exists</arg>
<arg>number</arg>
<arg>all</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
The <command>var</command> command retrieves information
about GET or POST variables sent to the script via client
request. It treats both GET and POST variables the same,
regardless of their origin. Note that there are two
additional forms of <command>::rivet::var</command>:
<command>rivet::var_qs</command> and
<command>::rivet::var_post</command>.
These two restrict the retrieval of information to
parameters arriving via the querystring
(?foo=bar&bee=bop) or POSTing, respectively.
</para>
<variablelist>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::var</command>
<arg choice="plain">get</arg>
<arg><replaceable>varname</replaceable></arg>
<arg><replaceable><optional>default</optional></replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the value of variable
<option><replaceable>varname</replaceable></option>
as a string (even if there are multiple values). If
the variable doesn't exist as a GET or POST
variable, the
<option><replaceable><optional>default</optional></replaceable></option>
value is returned, otherwise "" - an empty string -
is returned.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::var</command>
<arg choice="plain">list</arg>
<arg><replaceable>varname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the value of variable
<option><replaceable>varname</replaceable></option> as a list,
one list element per reference. Radiobuttons or multiple
selection listboxes are suited widgets which may
return list data.
</para>
<para>
If the result list is passed as a default value to the form package, one
could also set index "__varname" to get it interpreted as a list.
</para>
<programlisting>set response(countries) [::rivet::var list countries]
set response(__countries) ""
form form_request -defaults response
form_request select countries -multiple 1 -values {USA Canada Mexico}
form_request end</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::var</command>
<arg choice="plain">exists</arg>
<arg><replaceable>varname</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns 1 if
<option><replaceable>varname</replaceable></option>
exists, 0 if it doesn't.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::var</command>
<arg choice="plain">number</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Returns the number of variables.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<cmdsynopsis>
<command>::rivet::var</command>
<arg choice="plain">all</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Return a list of variable names and values.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>See <xref linkend="variable_access"/>.</para>
</refsect1>
</refentry>
<refentry id="wrap">
<refnamediv>
<refname>wrap</refname>
<refpurpose>
Split a string on newlines.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::wrap</command>
<arg>string</arg>
<arg>maxlen</arg>
<arg choice="plan">html</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
For each line, wrap the line at a space character to be
equal to or shorter than the maximum length value passed.
</para>
<para>
If a third argument called "-html" is present, the string is put together
with html <br> line breaks, otherwise it's broken with newlines.
</para>
</refsect1>
</refentry>
<refentry id="wrapline">
<refnamediv>
<refname>wrapline</refname>
<refpurpose>
Split the line into multiple lines by splitting on space characters
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::wrapline</command>
<arg>string</arg>
<arg>maxlen</arg>
<arg choice="plan">html</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Given a line and a maximum length and option "-html" argument, split the line
into multiple lines by splitting on space characters and making sure each line
is less than maximum length.
</para>
<para>
If the third argument, "-html", is present, return the result with the lines
separated by html <br> line breaks, otherwise the lines are returned
separated by newline characters.
</para>
</refsect1>
</refentry>
<refentry id="xml">
<refnamediv>
<refname>xml</refname>
<refpurpose>
XML Fragments creation
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::rivet::xml</command>
<arg>string</arg>
<arg>tag descriptor</arg>
<arg>tag descriptor</arg>
<arg>...</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
Given a string and a variable number of tag descriptors return XML fragment made
by nesting the tags with the same hierarchical order they are listed on the command
line. The tag descriptors can be a one element list (the tag) or an odd-length list whose
first argument is the tag name and the remaining elements are interpreted as
attribute name-attribute value pairs.
</para>
<para>
<command>::rivet::xml</command> can work as a replacement of <command>::rivet::html</command>
provided you take care of sending the string with command <command>puts</command>
</para>
<programlisting>::rivet::xml "a string" b u
<== <b><u>a string</u></b></programlisting>
<para>
You can tell the tags which attributes they must have
</para>
<programlisting><command>::rivet::xml "a string" [list div class box id testbox] b i</command>
<== <div class="box" id="testbox"><b><i>a string</i></b></div></programlisting>
<programlisting><command>::rivet::xml "text to be wrapped in XML" div [list a href "http://..../" title "info message"]</command>
<== <div><a href="http://..../" title="info message">text to be wrapped in XML</a></div></programlisting>
</refsect1>
</refentry>
</section>
|