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
|
<html>
<head>
<title>AOLserver</title>
</head>
<body>
<h1>General-Purpose C Library Functions</h1>
<p>
$Header: /cvsroot/aolserver/aolserver.com/docs/devel/c/index.html,v 1.1 2002/03/07 19:15:35 kriston Exp $
<p>
<h2><a name= href=./>Ns_AbsoluteUrl</a></h2>
Construct a URL from a URL and location
<h3>Syntax</h3>
<pre>
int Ns_AbsoluteUrl(
Ns_DString *pds,
char *url,
char *baseurl
);
</pre>
<h3>Description</h3>
The Ns_AbsoluteUrl function constructs a URL, based on url, which may
be incomplete, and baseurl, which is typically a location.
<h3>Examples</h3>
<pre>
Ns_DString ds;
Ns_DStringInit(&ds);
Ns_AbsoluteUrl(&ds, "/foo/bar.html", "http://www.foo.com:1234/");
The ds DString will contain "http://www.foo.com:1234/foo/bar.html".
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_AdpRegisterParser</a></h2>
Register a parser for ADPs.
<h3>Syntax</h3>
<pre>
int Ns_AdpRegisterParser (
char *name,
Ns_AdpParserProc *newParserProc
);
typedef void (Ns_AdpParserProc)(Ns_DString *out, char *in);
</pre>
<h3>Description</h3>
This registers a new ADP parser with the name "name". The
newParserProc will be called when an ADP is to be parsed. The content
of the ADP will be in the "in" parameter. The parser should parse it
and append appropriate output into the "out" parameter.
<p>
The output should be formatted as a series of concatenated "chunks". A
chunk is a string of the format:
<type character><string><null>
where:
<type character> = 't' or 's'. A 't' means what follows is HTML and should be returneddirectly to the browser. An 's' means what follows is Tcl and should be evaluated.
After the last chunk there should be an extra <null> character. For
example, the "adp" parser will take a page like this:
This is a test page<%ns_puts hi%>The end<%ns_puts bye%>
And create this output:
"tThis is a test page\0sns_puts hi\0tThe end\0sns_puts bye\0\0"
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_AuthorizeRequest</a></h2>
Check access of a method and URL
<h3>Syntax</h3>
<pre>
int Ns_AuthorizeRequest(
char *hServer,
char *method,
char *URL,
char *authuser,
char *authpasswd,
char *ipaddr
);
</pre>
<h3>Description</h3>
The Ns_AuthorizeRequest function is used to call the function
registered by Ns_SetRequestAuthorizeProc to authorize a user's access
to the given method and URL. Possible return values are:
<p>
NS_OK
<p>
The user's access is authorized.
<p>
NS_UNAUTHORIZED
<p>
Access is not public for this method or URL and either the user and
password were not verified or the user does not have permission.
<p>
NS_FORBIDDEN
<p>
There is no possible user/password combination that would give
authorization.
<p>
NS_ERROR
<p>
The authentication function could not perform the permission check.
<p>
<hr>
<br>
<h2><a name= href=./>Ns_AuthorizeUser</a></h2>
Check username and password
<h3>Syntax</h3>
<pre>
int Ns_AuthorizeUser(
char *user,
char *passwd
);
</pre>
<h3>Description</h3>
Checks that the cleartext password is correct for the specified user.
Returns NS_OK if it matches or NS_ERROR if not (or if no authorization
procedure is registered).
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetBool</a></h2>
Get a boolean configuration file variable
<h3>Syntax</h3>
<pre>
int Ns_ConfigGetBool(
char *hSection,
char *sKey,
int *pbValue
);
</pre>
<h3>Description</h3>
The Ns_ConfigGetBool function returns the boolean value of the
specified key (sKey) in the specified configuration file section
(hSection) and puts it into the integer pointed to by pbValue as a 1
or 0. Values of "1", "y", "yes", "on", "t", and "true" are 1, and
values of "0", "n", "no", "f", and "false" are 0. If any other value
is found, a warning is written to the log and NS_FALSE is returned.
Ns_ConfigGetBool returns NS_TRUE if a valid sKey exists and NS_FALSE
otherwise.
<h3>Examples</h3>
<pre>
int opt;
if (Ns_ConfigGetBool("MySect", "MyKey", &opt) != NS_TRUE) {
/* Option was not present or invalid - set a default. */
opt = 0; /* off */
}
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetInt</a></h2>
Get a configuration file integer variable
<h3>Syntax</h3>
<pre>
int Ns_ConfigGetInt(
char *sectionName,
char *key,
int *valuePtr
);
</pre>
<h3>Description</h3>
This function converts the specified value into an int and stores it
in valuePtr. If the key does not exist in the config file or it is not
an integer, the function returns NS_FALSE. Otherwise it returns
NS_TRUE.
<h3>Examples</h3>
<pre>
int n;
if (Ns_ConfigGetInt("MySect", "MyKey", &n) != NS_TRUE) {
/* Integer was not present or invalid - set a default. */
n = 5; /* off */
}
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetInt64</a></h2>
Get a configuration file 64-bit integer variable
<h3>Syntax</h3>
<pre>
int Ns_ConfigGetInt64(
char *hSection,
char *key,
INT64 *valuePtr
);
</pre>
<h3>Description</h3>
This function converts the specified value into an INT64 and stores it
in valuePtr. If the key does not exist in the config file or it is not
an integer, the function returns NS_FALSE. Otherwise it returns
NS_TRUE.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetPath</a></h2>
Return configuration file section name
<h3>Syntax</h3>
<pre>
char *Ns_ConfigGetPath(
char *hServer,
char *module,
...
);
</pre>
<h3>Description</h3>
The Ns_ConfigGetPath function returns a pointer to a configuration
file section name based on the server (hServer) and module specified.
The hServer or module may be NULL. A variable number of additional
path elements are appended. The list must end with NULL. For example,
Ns_ConfigGetPath("server1", NULL, "special", NULL) will return
"\NS\Server\server1\special" if such a section exists in the
configuration file and NULL if it does not.
<p>
The space for the string returned is located in the configuration
data. You do not need to deallocate the string and you must not alter
it.
<h3>Examples</h3>
<pre>
int
Ns_ModuleInit(char *hServer, char *hModule)
{
char *path;
char *value;
/*
* Construct the MySub section name specific to this
* server and module. For example, if hServer = "vs1"
* and hModule = "mymod", path would be:
* [ns/server/vs1/module/mymod/MySudb]
*/
path = Ns_ConfigGetPath(hServer, hModule, "MySub", NULL);
value = Ns_ConfigGetValue(path, "MyKey");
...
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetSection</a></h2>
Get the Ns_Set for a configuration file section
<h3>Syntax</h3>
<pre>
Ns_Set *Ns_ConfigGetSection(
char *sectionName
);
</pre>
<h3>Description</h3>
This function returns the entire section as an Ns_Set, where the
fields of the set correspond to the entries of the section in the
config file. The fields are stored in the Ns_Set in the same order in
which they appear in the configuration file section. This is useful if
you want to loop through all the entries of a section. If the section
does not exist, Ns_ConfigGetSection returns NULL.
<p>
The Ns_Set returned is located in the configuration data. You do not
need to free the set and you must not alter it.
<h3>Examples</h3>
<pre>
Ns_Set *section;
int i;
char *key;
/* Log the keys of the "MySection" config section. */
section = Ns_ConfigGetSection("MySection");
for (i = 0; i < Ns_SetSize(section); ++i) {
key = Ns_SetKey(section, i);
Ns_Log(Notice, "key %d: %s", i, key);
}
...
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetSections</a></h2>
Return Ns_Sets with configuration file data
<h3>Syntax</h3>
<pre>
Ns_Set **Ns_ConfigGetSections(void);
</pre>
<h3>Description</h3>
The Ns_ConfigGetSections function allocates and returns a
null-terminated list of Ns_Sets. Each Ns_Set structure contains the
configuration file data for a configuration file section.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetValue</a></h2>
Get a configuration file variable
<h3>Syntax</h3>
<pre>
char *Ns_ConfigGetValue(
char *sectionName,
char *key
);
</pre>
<h3>Description</h3>
This function returns the value for the given key in the section named
sectionName. If either the section does not exist or the key does not
exist in the section, the function returns NULL. If multiple keys of
the same name are in the named section (for example, the multiple Load
lines of the Modules section), this function returns only the first
matching entry. The section names must match exactly, but the key will
be matched case-insensitively. Ns_ConfigGetValueExact is the
case-sensitive counterpart of this function.
<p>
The space for the string returned is located in the configuration
data. You must not deallocate or modify the string.
<h3>Examples</h3>
<pre>
/* Fetch the home directory of the AOLserver. */
char *home;
home = Ns_ConfigGetValue("ns/parameters", "Home");
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ConfigGetValueExact</a></h2>
Get configuration variable case-sensitively
<h3>Syntax</h3>
<pre>
char *Ns_ConfigGetValueExact(
char *sectionName,
char *key,
);
</pre>
<h3>Description</h3>
The Ns_ConfigGetValueExact function is a case-sensitive counterpart to
the Ns_ConfigGetValue function. It matches both the section name and
the key case-sensitively. It returns the value for the given key in
the section named sectionName.
<p>
The space for the string returned is located in the configuration
data. You must not deallocate or modify the string.
<h3>Examples</h3>
<pre>
See the example for Ns_ConfigGetValue.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_DecodeUrl</a></h2>
Decode URL query data
<h3>Syntax</h3>
<pre>
char *Ns_DecodeUrl(
Ns_DString *pds,
char *data
);
</pre>
<h3>Description</h3>
The Ns_DecodeUrl function decodes data that were encoded as URL query
data. The decoded data are appended to the given Ns_DString. This
function can be used to decode arguments that were passed as URL query
data following a `?'. The return value is the value of pds->string,
i.e., the address of the character array.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_DStringAppend</a></h2>
Append a string to an Ns_DString
<h3>Syntax</h3>
<pre>
char *Ns_DStringAppend(
Ns_DString *dsPtr,
char *string
);
</pre>
<h3>Description</h3>
The Ns_DStringAppend macro appends the specified string plus a
terminating null character to the end of the Ns_DString. The string
may overflow from static space to the heap as a result of calling this
function. It returns the string associated with the current
Ns_DString.
<h3>Examples</h3>
<pre>
Ns_DString ds;
Ns_DStringInit(&ds);
Ns_DStringAppend(&ds, "foo");
/* do something with the dstring */
printf("%s\n", ds.string);
Ns_DStringFree(&ds); /* finished with dstring */
The resulting Ns_DString, ds, would contain "foo\0" and have a length
of 3.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_DStringAppendArg</a></h2>
Append argument to an Ns_DString
<h3>Syntax</h3>
<pre>
char *Ns_DStringAppendArg(
Ns_DString *dsPtr,
char *arg
);
</pre>
<h3>Description</h3>
<h2><a name= href=./>Ns_EncodeUrl</a></h2>
Encode URL query data
<h3>Syntax</h3>
<pre>
char *Ns_EncodeUrl(
Ns_DString *pds,
char *data
);
</pre>
<h3>Description</h3>
The Ns_EncodeUrl function encodes the data as URL query data and
appends the encoded data to the given Ns_DString. All characters
except the alphanumerics are encoded as specified in RFC1738, Uniform
Resource Locators. This function can be used to append arguments to a
URL as query data following a `?'.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_Encrypt</a></h2>
Encrypt key
<h3>Syntax</h3>
<pre>
char *Ns_Encrypt(
char *key,
char *salt,
char buf[]
);
</pre>
<h3>Description</h3>
The Ns_Encrypt function encrypts the specified key, perturbed by salt.
The result is returned in buf, which should be at least
NS_ENCRYPT_BUFSIZE bytes in size.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_FetchPage</a></h2>
Copy data from URL to dynamic string
<h3>Syntax</h3>
<pre>
int Ns_FetchPage(
Ns_DString *pds,
char *url,
char *hServer
);
</pre>
<h3>Description</h3>
The Ns_FetchPage function copies data from url to the Ns_DString
pointed to by pds. The URL must be relative and must correspond to a
file served by this server. Ns_FetchPage returns a status of NS_OK or
NS_ERROR.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_FetchURL</a></h2>
Fetch a remote URL.
<h3>Syntax</h3>
<pre>
int Ns_FetchURL(
Ns_DString *pds,
char *URL,
Ns_Set *headers
);
</pre>
<h3>Description</h3>
The Ns_FetchURL function connects the AOLserver to another HTTP Web
server and requests the specified URL. The URL must be fully
qualified. The content is appended to the given Ns_DString. If the
headers is not NULL, the HTTP headers returned in the response from
the remote server are appended to the set. Ns_FetchUrl does not
currently handle redirects or requests for any protocol except HTTP.
Use Ns_FetchPage to get pages on the local server.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_FreeRequest</a></h2>
Free memory used by an Ns_Request
<h3>Syntax</h3>
<pre>
void Ns_FreeRequest(
Ns_Request *request
);
</pre>
<h3>Description</h3>
The Ns_FreeRequest function frees the members of the Ns_Request and
then frees the Ns_Request structure itself. The request is no longer
valid and must not be used after a call to Ns_FreeRequest.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_GetConnInterp</a></h2>
Get the Tcl interpreter for the connection
<h3>Syntax</h3>
<pre>
EXTERN Tcl_Interp *Ns_GetConnInterp(
Ns_Conn *conn
);
</pre>
<h3>Description</h3>
This function, given the conn, returns the interpreter already
assigned to the conn if one exists. If no interpreter is assigned, it
allocates a new interpreter and assigns it to the conn. By using this
function, you can be certain that the same interpreter (and its global
state) are used by the registered request function and the filters.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_GetMimeType</a></h2>
Get Mime type
<h3>Syntax</h3>
<pre>
char* Ns_GetMimeType (
char* file
);
</pre>
<h3>Description</h3>
Guess the Mime type based on the filename extension. Case is ignored.
The return value is of the form: "text/html".
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_GetRequest</a></h2>
Return the parameters of a request
<h3>Syntax</h3>
<pre>
typedef void *Ns_OpContext;
typedef int (Ns_OpProc) (void *context, Ns_Conn *conn);
typedef void (Ns_OpDeleteProc) (void *context);
void Ns_GetRequest(
char *hServer
char *method,
char *URL,
Ns_OpProc **pProc,
Ns_OpDeleteProc **pDeleteProc,
Ns_OpContext **pContext
int *pflags
);
</pre>
<h3>Description</h3>
The Ns_GetRequest function sets pproc to the procedure the server
would call to handle a request of method and URL on the specified
server. pContext is set to the context that would be passed to pProc
when called, and pDeletepProc is set to the delete procedure that
would be called if pProc were unregistered (or re-registered). pflags
points to the flags argument passed to Ns_RegisterRequest. The
function returned is the best matching function and not necessarily an
exact matching function.
<p>
You can use Ns_GetRequest and the NS_OP_NODELETE flag for
Ns_RegisterRequest to implement wrapper-type operation, where you save
the operation function, delete procedure, and context and register a
new function that does some type of pre-processing before calling the
operation or delete procedures.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_HtuuDecode</a></h2>
Perform base64 decode
<h3>Syntax</h3>
<pre>
int Ns_HtuuDecode (
char* string,
unsigned char* buf,
int bufsize
);
</pre>
<h3>Description</h3>
Performs a base64 decode on string and writes the result into buf.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_HtuuEncode</a></h2>
Perform base64 encode
<h3>Syntax</h3>
<pre>
int Ns_HtuuEncode (
unsigned char* string,
unsigned int bufsize,
char* buf
);
</pre>
<h3>Description</h3>
Performs a base64 encode on string and writes the result into buf.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_Match</a></h2>
Compare strings
<h3>Syntax</h3>
<pre>
char* Ns_Match (
char* pattern,
char* string
);
</pre>
<h3>Description</h3>
Compare the beginnings of two strings, case insensitively. The
comparison stops when the end of the shorter string is reached.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_NextWord</a></h2>
Find next word in string
<h3>Syntax</h3>
<pre>
char* Ns_NextWord (
char* line
);
</pre>
<h3>Description</h3>
Find the next word (after whiteaspace) in a string.
<p>
For example, Ns_NextWord("abc def") returns a pointer to the 'd' in
that string.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ParseHeader</a></h2>
Parse Http headers
<h3>Syntax</h3>
<pre>
int Ns_ParseHeader (
Ns_Set* psetHeaders,
char* sHeader,
...
);
</pre>
<h3>Description</h3>
Parse http headers into the Ns_Set. The trailing arguments exist for
backwards compatibility and are ignored.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ParseRequest</a></h2>
Parse an HTTP request line into an Ns_Request
<h3>Syntax</h3>
<pre>
Ns_Request *Ns_ParseRequest(
char *requestLine
);
</pre>
<h3>Description</h3>
The Ns_ParseRequest function takes an HTTP request line and returns a
newly allocated Ns_Request structure. You must eventually call
Ns_FreeRequest to free the memory used by the Ns_Request structure and
its members.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ParseUrl</a></h2>
Parse a URL
<h3>Syntax</h3>
<pre>
int Ns_ParseUrl(
char *url,
char **pprotocol,
char **phost,
char **pport,
char **ppath,
char **ptail
);
</pre>
<h3>Description</h3>
Parse a URL into its component parts. Pointers to the protocol, host,
port, path, and "tail" (last path element) will be set by reference in
the passed-in pointers. The passed-in url will be modified. Return
NS_OK on success or NS_ERROR on failure.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_PermPasswordCheck</a></h2>
Check user's encrypted password
<h3>Syntax</h3>
<pre>
int Ns_PermPasswordCheck(
char *user,
char *password
);
</pre>
<h3>Description</h3>
Validate a user's encrypted password. This function is only accessible
if the nsperm module is loaded. NS_TRUE is returned if the password is
correct.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_QuoteHtml</a></h2>
Quote an HTML string
<h3>Syntax</h3>
<pre>
void Ns_QuoteHtml(
Ns_DString *pds,
char *string
);
</pre>
<h3>Description</h3>
The Ns_QuoteHtml function appends the given string to the Ns_DString,
making the following substitutions that allow HTML to be included in
another HTML page as plain text:
<p>
<
<p>
<
<p>
>
<p>
>
<p>
&
<p>
&
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterCleanup</a></h2>
Register a procedure for connection cleanup trace
<h3>Syntax</h3>
<pre>
void *Ns_RegisterCleanup(
Ns_TraceProc *proc,
void *arg
);
</pre>
<h3>Description</h3>
Register a connection cleanup trace procedure. Traces registered with
this procedure are always called in LIFO order at the end of
connection, regardless of the result code from the connection's
request procedure. In other words, the procedure is called even if the
client drops connection.
<p>
It returns a pointer to the trace.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterFilter</a></h2>
Register a filter function to handle a method/URL combination
<h3>Syntax</h3>
<pre>
typedef int (Ns_FilterProc) (void *context, Ns_Conn *conn, int
why);
Ns_ProcHandle Ns_RegisterFilter(
char *hServer,
char *method,
char *URLpatterns,
Ns_FilterProc *proc,
int why,
void *context
);
</pre>
<h3>Description</h3>
This function will register a filter procedure for a method/URL
combination on a server. This function will be called at the specified
stage of a connection, if the method/URL combination for the filter
matches the method/URL combination for the connection using glob style
matching. The procedures are run in last-registered last-run order. A
filter procedure is often used for logging.
<p>
The why argument can be any of the following, or some combination of
them by bitwise OR-ing (with "|") them together:
<p>
NS_FILTER_PRE_AUTH: the filter will be called before
authorization of a page
NS_FILTER_POST_AUTH: the filter will be called after
authorization but before a page has been returned
NS_FILTER_TRACE: the filter will be called after the connection
has been totally processed
Using pre-authorization, the procedure will be called (assuming that
the method/URL combination matches) just before authorization. If the
procedure returns:
* NS_OK: The server will continue to the next pre-authorization
filter for this connection, or, if there are no more
pre-authorization filters, it will continue on with authorization.
* NS_FILTER_BREAK: The server will not process any more
pre-authorization filters for this connection, and it will
continue on with authorization.
* NS_FILTER_RETURN: The server will close the connection and will
not run any more pre-authorization filters. It will not authorize
the request, and it will not run the function registered for this
METHOD/URL. It WILL run any trace functions registered for this
METHOD/URL, usually including logging. It is assumed that the
filter has returned a proper response to the client before
returning NS_FILTER_RETURN.
Using post-authorization, the procedure will be called (assuming that
the method/URL combination matches) just after successful
authorization. If the procedure returns:
* NS_OK: The server will continue to the next post-authorization
filter for this connection, or, if there are no more
post-authorization filters, it will run the function registered to
handle this request.
* NS_FILTER_BREAK: The server will not process any more
post-authorization filters for this connection, and it will run
the function registered to handle this request.
* NS_FILTER_RETURN: The server will close the connection and will
not run any more post-authorization filters and it will not run
the function registered for this METHOD/URL. It WILL run any trace
functions registered for this METHOD/URL, usually including
logging. It is assumed that the filter has returned a proper
response to the client before returning NS_FILTER_RETURN.
Using trace, the procedure will be called (assuming that the
method/URL combination match) after the connection has been totally
processed and closed. If the procedure returns:
* NS_OK: The server will continue to the next trace filter.
* NS_FILTER_BREAK, NS_FILTER_RETURN: The rest of the trace filters
are ignored
The URLpatterns can contain standard string-matching characters. For
example, these are valid URLpatterns:
<p>
/employees/*.tcl
/accounts/*/out
<h3>Examples</h3>
<pre>
static int
ReportUse(void *context, Ns_Conn *conn, int why){
int status=NS_OK;
switch(why){
case NS_FILTER_PRE_AUTH:
Ns_Log(Notice, "User trying to access %s",conn->request->url);
break;
case NS_FILTER_POST_AUTH:
Ns_Log(Notice, "User authorized to access %s",conn->request-
>url);
break;
case NS_FILTER_TRACE:
Ns_Log(Notice, "User has retrieved %s",conn->request->url);
break;
default:
status=NS_ERROR;
}
return status;
}
int
Ns_ModuleInit(char *hServer, char *hModule){
Ns_RegisterFilter(hServer, "GET", "/test/a*", ReportUse,
Ns_FILTER_PRE_AUTH, NULL);
Ns_RegisterFilter(hServer, "GET", "/test/b*", ReportUse,
Ns_FILTER_POST_AUTH, NULL);
Ns_RegisterFilter(hServer, "GET", "/test/c*", ReportUse,
Ns_FILTER_TRACE, NULL);
Ns_RegisterFilter(hServer, "GET", "/test/d*", ReportUse,
Ns_FILTER_PRE_AUTH | NS_FILTER_POST_AUTH, NULL);
Ns_RegisterFilter(hServer, "GET", "/test/e*", ReportUse,
Ns_FILTER_POST_AUTH | NS_FILTER_TRACE, NULL);
Ns_RegisterFilter(hServer, "GET", "/test/f*", ReportUse,
Ns_FILTER_PRE_AUTH | Ns_FILTER_POST_AUTH | NS_FILTER_TRACE,
NULL);
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterProxyRequest</a></h2>
Register a function to proxy requests for a method/protocol
combination
<h3>Syntax</h3>
<pre>
typedef void *Ns_OpContext;
typedef int (Ns_OpProc) (void *context, Ns_Conn *conn);
typedef void (Ns_OpDeleteProc) (void *context);
void Ns_RegisterProxyRequest(
char *Server,
char *method,
char *protocol,
Ns_OpProc *proc,
Ns_Callback *deleteProc,
void *context
);
</pre>
<h3>Description</h3>
The Ns_RegisterProxyRequest function registers function proc to handle
HTTP requests. When the specified server receives a proxy request, it
finds the appropriate registered function.
<p>
The server passes your procedure the context you specify here and the
Ns_Conn structure associated with the new HTTP connection.
<p>
When a procedure is unregistered with either
Ns_UnRegisterProxyRequest, the server calls the deleteProc with the
same context. You can use this to do any cleanup you might require
(e.g., close an index file or free something from the heap). If the
value of deleteProc is NULL, the server does nothing.
<h3>Examples</h3>
<pre>
See the example in the examples/c/nsproxy directory.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterRequest</a></h2>
Register one or two functions to handle HTTP requests for a method/URL
combination
<h3>Syntax</h3>
<pre>
typedef void *Ns_OpContext;
typedef int (Ns_OpProc) (void *context, Ns_Conn *conn);
typedef void (Ns_OpDeleteProc) (void *context);
void Ns_RegisterRequest(
char *hServer,
char *method,
char *URL,
Ns_OpProc *proc,
Ns_OpDeleteProc *deleteProc,
Ns_OpContext context,
int flags
);
</pre>
<h3>Description</h3>
The Ns_RegisterRequest function registers function proc to handle HTTP
requests. When the specified server receives an HTTP request, it finds
the most specific registered operation. The default operation for a
GET (i.e., the one registered with URL \Q/') serves up a page out of
the file system.
<p>
The server passes your procedure the context you specify here and the
Ns_Conn structure associated with the new HTTP connection.
<p>
When a procedure is unregistered with either Ns_UnRegisterRequest or
by registering another procedure with the same method and URL, the
server calls the deleteProc with the same context. You can use this to
do any cleanup you might require (e.g., close an index file or free
something from the heap). If the value of deleteProc is NULL, the
server does nothing.
<p>
The flags parameter specifies one or more constants that can be OR'ed
together. The available flags are NS_OP_NOINHERIT and NS_OP_NODELETE.
<p>
NS_OP_NOINHERIT tells AOLserver to only call your procedure if the URL
matches exactly (the default behavior is to look for the closest
match). You can register two procedures for the same method/URL
combination by calling Ns_RegisterRequest once with NS_OP_NOINHERIT
specified and once without NS_OP_NOINHERIT specified. The first
procedure will be called if there is an exact match with the specified
URL. The second procedure will be called if the requested URL is below
the specified URL, provided there is not already another procedure
registered with a closer match.
<p>
NS_OP_NODELETE specifies that the previous procedure's deleteproc
should not be called. NS_OP_NODELETE can be used in conjunction with
Ns_GetRequest to implement wrappers.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterReturn</a></h2>
Register a return status for a URL
<h3>Syntax</h3>
<pre>
void Ns_RegisterReturn (
int status,
char* url
);
</pre>
<h3>Description</h3>
Associate a URL with a return status (for custom error pages). For
exmaple:
Ns_RegisterReturn(404, "http://www.foo.com/notfound.html");
will send redirects to http://www.foo.com/notfound.html whenever a 404
error is to be returned.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterServerTrace</a></h2>
Register a trace procedure for a server.
<h3>Syntax</h3>
<pre>
typedef void (Ns_TraceProc) (void *context, Ns_Conn *conn);
Ns_ProcHandle Ns_RegisterServerTrace(
char *hServer,
Ns_TraceProc *proc,
void *context
);
</pre>
<h3>Description</h3>
The Ns_RegisterServerTrace function registers proc as a trace for the
specified server. The server calls all trace procedures after every
HTTP connection with the context and the Ns_Conn for that connection.
The procedures are run in last-registered first-run order. A trace
procedure is often used for logging.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RelativeUrl</a></h2>
Get relative filename portion of URL
<h3>Syntax</h3>
<pre>
char *Ns_RelativeUrl(
char *url,
char *location
);
</pre>
<h3>Description</h3>
Given a URL and a location, Ns_RelativeUrl returns a pointer to the
relative filename portion of the specified URL. The example below
returns a pointer to /index.html.
<h3>Examples</h3>
<pre>
/* returns a pointer to /index.html */
Ns_RelativeUrl("http://www.foo.com/index.html",
"http://www.foo.com");
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_SkipUrl</a></h2>
Skip past path elements in the URL of a request
<h3>Syntax</h3>
<pre>
char *Ns_SkipUrl(
Ns_Request *request,
int nurl
);
</pre>
<h3>Description</h3>
The Ns_SkipUrl function returns the request URL after skipping past
the first nurl elements.
<h3>Examples</h3>
<pre>
/* PathInfo - Request to return URL after the first 2 parts. */
int
PathInfo(Ns_Conn *conn, void *ctx)
{
char *info;
/* Skip past the first two parts */
info = Ns_SkipUrl(conn->request, 2);
return Ns_ConnReturnNotice(conn, 200, info, NULL);
}
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrCaseFind</a></h2>
Perform strstr
<h3>Syntax</h3>
<pre>
char* Ns_StrCaseFind (
char* string,
char* substr
);
</pre>
<h3>Description</h3>
This function performs a case-insensitive strstr(3C).
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrCopy</a></h2>
Copy a string or NULL value using Ns_Malloc
<h3>Syntax</h3>
<pre>
char *Ns_StrCopy(
char *string
);
</pre>
<h3>Description</h3>
The Ns_StrCopy function is identical to the Ns_StrDup function but
allows for the string parameter to be NULL, in which case Ns_StrCopy
does nothing and returns NULL.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrDup</a></h2>
Copy a string using Ns_Malloc
<h3>Syntax</h3>
<pre>
char *Ns_StrDup(
char *string
);
</pre>
<h3>Description</h3>
The Ns_StrDup function calls Ns_Malloc to allocate enough memory to
make a copy of the given string. This function replaces the system
strdup function.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StringPrint</a></h2>
Print string
<h3>Syntax</h3>
<pre>
void Ns_StringPrint (
char* s
);
</pre>
<h3>Description</h3>
This function prints the specified string to stdout.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_Strtok</a></h2>
Perform strtok_r
<h3>Syntax</h3>
<pre>
char* Ns_Strtok (
char* s1,
const char* s2
);
</pre>
<h3>Description</h3>
This function wraps strtok_r(3C).
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrToLower</a></h2>
Lowercase string
<h3>Syntax</h3>
<pre>
char* Ns_StrToLower (
char* string
);
</pre>
<h3>Description</h3>
This function converts the specified string to lowercase.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrToUpper</a></h2>
Uppercase string
<h3>Syntax</h3>
<pre>
char* Ns_StrToUpper (
char* string
);
</pre>
<h3>Description</h3>
This function converts the specified string to uppercase.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrTrim</a></h2>
Trim string
<h3>Syntax</h3>
<pre>
char* Ns_StrTrim (
char* string
);
</pre>
<h3>Description</h3>
This function trims all blanks from the specified string.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrTrimLeft</a></h2>
Trim blanks from left
<h3>Syntax</h3>
<pre>
char* Ns_StrTrimLeft (
char* string
);
</pre>
<h3>Description</h3>
This function trims all blanks from the left of the string.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_StrTrimRight</a></h2>
Trim blanks from right
<h3>Syntax</h3>
<pre>
char* Ns_StrTrimRight (
char* string
);
</pre>
<h3>Description</h3>
This function trims all blanks from the right of the string.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclAllocateInterp</a></h2>
Allocate an interpreter for a server
<h3>Syntax</h3>
<pre>
Tcl_Interp *Ns_TclAllocateInterp(
char *hServer
);
</pre>
<h3>Description</h3>
This function reserves and returns a Tcl interpreter associated with
the server. You will usually want to use the Ns_GetConnInterp function
instead, since connections often already have interpreters associated
with them.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclAppendInt</a></h2>
Append integer to Tcl result
<h3>Syntax</h3>
<pre>
void Ns_TclAppendInt (
Tcl_Interp* interp,
int value
);
</pre>
<h3>Description</h3>
Append an integer to the Tcl result. This is essentially a safe
version of sprintf(interp->result, "%d", value).
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclDeAllocateInterp</a></h2>
Perform cleanup after deallocating a Tcl interpreter
<h3>Syntax</h3>
<pre>
int Ns_TclDeAllocateInterp(
Tcl_Interp *interp
);
</pre>
<h3>Description</h3>
This function is called automatically after each Tcl request procedure
if the AutoClose configuratin parameter is set on. Sets created by
Ns_TclEnterSet are deleted or not deleted, depending on the flags set
in the Ns_TclEnterSet function.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclDestroyInterp</a></h2>
Mark Tcl interpreter for deletion
<h3>Syntax</h3>
<pre>
void Ns_TclDestroyInterp (
Tcl_Interp*
);
</pre>
<h3>Description</h3>
Mark the Tcl interpreter for deletion. At thread death, clean up its
state, close files, free memory, etc.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclEval</a></h2>
Execute a Tcl script
<h3>Syntax</h3>
<pre>
int Ns_TclEval (
Ns_DString *pds,
char *hServer
char *script
);
</pre>
<h3>Description</h3>
The Ns_TclEval function executes the Tcl function specified by script
on the server specified by hServer. It writes the results to the
passed-in pds variable.
<p>
Note that the string in script may be temporarily modified by Tcl, so
it must be writable. For example, use:
char script[*]="sometcl";
instead of:
char *script="sometcl";
<h3>Examples</h3>
<pre>
Use this code to call ns_sendmail from C:
NS_DStringVarAppend(&dsScript, "ns_sendmail", to, " ",
from, " ", subject, " ", body);
status=Ns_TclEval(&dsResult, Ns_ConnServer(conn),
dsScript.string)
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclGetOpenChannel</a></h2>
Get open channel in interpreter
<h3>Syntax</h3>
<pre>
int Ns_TclGetOpenChannel (
Tcl_Interp* ,
char* chanId,
int write,
int check,
Tcl_Channel* channPtr
);
</pre>
<h3>Description</h3>
This function fills in channptr with a channel open in the passed-in
interpreter if one exists. It returns TCL_OK or TCL_ERROR. The chanId
is a channel name (the handle that Tcl uses).
<p>
This function also has the ability to check if a channel is opened for
reading or writing. If check is true, the check is performed. If write
is true, the channel is checked for writeability. If write is false,
the channel is checked for readability. If the check is performed and
fails, then an error is returned and appended to the interpreter.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclGetOpenFd</a></h2>
Get open file descriptor
<h3>Syntax</h3>
<pre>
int Ns_TclGetOpenFd (
Tcl_Interp* ,
char* chanId,
int write,
int* fdPtr
);
</pre>
<h3>Description</h3>
This function returns an open Unix file descriptor for the specified
channel. The value at fdPtr is updated with a valid Unix file
descriptor.
<p>
The write parameter specifies if a writable (TRUE) or readable (FALSE)
channel is being requested. See the Tcl 7.6 documentation for
Tcl_GetChannelFile.
<p>
This function returns TCL_ERROR or TCL_OK.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclInitInterps</a></h2>
Call a Tcl init procedure in the parent interpreter
<h3>Syntax</h3>
<pre>
int Ns_TclInitInterps(
char *hServer,
Ns_TclInterpInitProc *proc,
void *context
);
</pre>
<h3>Description</h3>
Ns_TclInitInterps runs the specified procedure (proc) in the parent
interpreter of the specified server. The definition of
Ns_TclInterpInitProc is:
typedef int (Ns_TclInterpInitProc) (Tcl_Interp *interp, void
*context);
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclInitModule</a></h2>
Source Tcl module before server startup
<h3>Syntax</h3>
<pre>
int Ns_TclInitModule (
char* server,
char* module
);
</pre>
<h3>Description</h3>
Put this module on this list of modules whose Tcl is to be sourced
before server startup and after modules are loaded. The server
parameter is ignored.
<p>
For example, calling Ns_TclInitModule(NULL, "nsfoo") from
Ns_ModuleInit will cause the following directories to be sourced after
all modules are loaded:
<p>
(aolserver home)/servers/server1/modules/tcl/nsfoo/*.tcl
(aolserver home)/modules/tcl/nsfoo/*.tcl
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclInterpServer</a></h2>
Return name of server
<h3>Syntax</h3>
<pre>
char* Ns_TclInterpServer (
Tcl_Interp* interp
);
</pre>
<h3>Description</h3>
Return the name of the server, such as "server1". The interp argument
is ignored.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclLibrary</a></h2>
Return private Tcl directory
<h3>Syntax</h3>
<pre>
char* Ns_TclLibrary (void);
</pre>
<h3>Description</h3>
This function returns the name of the private Tcl directory, such as
"(aolserver home)/servers/server1/modules/tcl".
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclLogError</a></h2>
Write errorInfo to log file
<h3>Syntax</h3>
<pre>
char* Ns_TclLogError (
Tcl_Interp* interp
);
</pre>
<h3>Description</h3>
This function writes the value of the errorInfo variable out to the
log. See the Tcl documentation for more on the global errorInfo
variable.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclMarkForDelete</a></h2>
Mark Tcl interpreter for deletion
<h3>Syntax</h3>
<pre>
void Ns_TclMarkForDelete (
Tcl_Interp*
);
</pre>
<h3>Description</h3>
Mark this interpreter for deletion. When the thread terminates (and it
must be a connection thread), the tcl interpreter will be deleted.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_UnRegisterProxyRequest</a></h2>
Unregister a proxy request function
<h3>Syntax</h3>
<pre>
void Ns_UnRegisterProxyRequest(
char *Server,
char *method,
char *protocol
);
</pre>
<h3>Description</h3>
The Ns_UnRegisterProxyRequest function unregisters the function for
the specified method and protocol on a specific server. If the
deleteProc is not null, it is called with the function's context as an
argument.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_UnRegisterRequest</a></h2>
Unregister a function
<h3>Syntax</h3>
<pre>
void Ns_UnRegisterRequest(
char *hServer,
char *method,
char *URL,
int flags
);
</pre>
<h3>Description</h3>
The Ns_UnRegisterRequest function unregisters the function with the
specified method/URL combination and with the same inheritance setting
on a specific server. That is, if the flags argument is set to
NS_OP_NOINHERIT in Ns_UnRegisterRequest, the function registered with
the NS_OP_NOINHERIT flag in Ns_RegisterRequest (or the -noinherit flag
in ns_register_proc) will be unregistered. If the flags argument is
set to 0, the function registered without the NS_OP_NOINHERIT flag (or
the -noinherit flag) will be unregistered.
</pre>
<p>
<hr>
<br>
</body>
</html>
|