[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
[0071]
[0072]
[0073]
[0074]
[0075]
[0076]
[0077]
[0078]
[0079]
[0080]
[0081]
[0082]
[0083]
[0084]
[0085]
[0086]
[0087]
[0088]
[0089]
[0090]
[0091]
[0092]
[0093]
[0094]
[0095]
[0096]
[0097]
[0098]
[0099]
[0100]
[0101]
[0102]
[0103]
[0104]
[0105]
[0106]
[0107]
[0108]
[0109]
[0110]
[0111]
[0112]
[0113]
[0114]
[0115]
[0116]
[0117]
[0118]
[0119]
[0120]
[0121]
[0122]
[0123]
[0124]
[0125]
[0126]
[0127]
[0128]
[0129]
[0130]
[0131]
[0132]
[0133]
[0134]
[0135]
[0136]
[0137]
[0138]
[0139]
[0140]
[0141]
[0142]
[0143]
[0144]
[0145]
[0146]
[0147]
[0148]
[0149]
[0150]
[0151]
[0152]
[0153]
[0154]
[0155]
[0156]
[0157]
[0158]
[0159]
[0160]
[0161]
[0162]
[0163]
[0164]
[0165]
[0166]
[0167]
[0168]
[0169]
[0170]
[0171]
[0172]
[0173]
[0174]
[0175]
[0176]
[0177]
[0178]
[0179]
[0180]
[0181]
[0182]
[0183]
[0184]
[0185]
[0186]
[0187]
[0188]
[0189]
[0190]
[0191]
[0192]
[0193]
[0194]
[0195]
[0196]
[0197]
[0198]
[0199]
[0200]
[0201]
[0202]
[0203]
[0204]
[0205]
[0206]
[0207]
[0208]
[0209]
[0210]
[0211]
[0212]
[0213]
[0214]
[0215]
[0216]
[0217]
[0218]
[0219]
[0220]
[0221]
[0222]
[0223]
[0224]
[0225]
[0226]
[0227]
[0228]
[0229]
[0230]
[0231]
[0232]
[0233]
[0234]
[0235]
[0236]
[0237]
[0238]
[0239]
[0240]
[0241]
[0242]
[0243]
[0244]
[0245]
[0246]
[0247]
[0248]
[0249]
[0250]
[0251]
[0252]
[0253]
[0254]
[0255]
[0256]
[0257]
[0258]
[0259]
[0260]
[0261]
[0262]
[0263]
[0264]
[0265]
[0266]
[0267]
[0268]
[0269]
[0270]
[0271]
[0272]
[0273]
[0274]
[0275]
[0276]
[0277]
[0278]
[0279]
[0280]
[0281]
[0282]
[0283]
[0284]
[0285]
[0286]
[0287]
[0288]
[0289]
[0290]
[0291]
[0292]
[0293]
[0294]
[0295]
[0296]
[0297]
[0298]
[0299]
[0300]
[0301]
[0302]
[0303]
[0304]
[0305]
[0306]
[0307]
[0308]
[0309]
[0310]
[0311]
[0312]
[0313]
[0314]
[0315]
[0316]
[0317]
[0318]
[0319]
[0320]
[0321]
[0322]
[0323]
[0324]
[0325]
[0326]
[0327]
[0328]
[0329]
[0330]
[0331]
[0332]
[0333]
[0334]
[0335]
[0336]
[0337]
[0338]
[0339]
[0340]
[0341]
[0342]
[0343]
[0344]
[0345]
[0346]
[0347]
[0348]
[0349]
[0350]
[0351]
[0352]
[0353]
[0354]
[0355]
[0356]
[0357]
[0358]
[0359]
[0360]
[0361]
[0362]
[0363]
[0364]
[0365]
[0366]
[0367]
[0368]
[0369]
[0370]
[0371]
[0372]
[0373]
[0374]
[0375]
[0376]
[0377]
[0378]
[0379]
[0380]
[0381]
[0382]
[0383]
[0384]
[0385]
[0386]
[0387]
[0388]
[0389]
[0390]
[0391]
[0392]
[0393]
[0394]
[0395]
[0396]
[0397]
[0398]
[0399]
[0400]
[0401]
[0402]
[0403]
[0404]
[0405]
[0406]
[0407]
[0408]
[0409]
[0410]
[0411]
[0412]
[0413]
[0414]
[0415]
[0416]
[0417]
[0418]
[0419]
[0420]
[0421]
[0422]
[0423]
[0424]
[0425]
[0426]
[0427]
[0428]
[0429]
[0430]
[0431]
[0432]
[0433]
[0434]
[0435]
[0436]
[0437]
[0438]
[0439]
[0440]
[0441]
[0442]
[0443]
[0444]
[0445]
[0446]
[0447]
[0448]
[0449]
[0450]
[0451]
[0452]
[0453]
[0454]
[0455]
[0456]
[0457]
[0458]
[0459]
[0460]
[0461]
[0462]
[0463]
[0464]
[0465]
[0466]
[0467]
[0468]
[0469]
[0470]
[0471]
[0472]
[0473]
[0474]
[0475]
[0476]
[0477]
[0478]
[0479]
[0480]
[0481]
[0482]
[0483]
[0484]
[0485]
[0486]
[0487]
[0488]
[0489]
[0490]
[0491]
[0492]
[0493]
[0494]
[0495]
[0496]
[0497]
[0498]
[0499]
[0500]
[0501]
[0502]
[0503]
[0504]
[0505]
[0506]
[0507]
[0508]
[0509]
[0510]
[0511]
[0512]
[0513]
[0514]
[0515]
[0516]
[0517]
[0518]
[0519]
[0520]
[0521]
[0522]
[0523]
[0524]
[0525]
[0526]
[0527]
[0528]
[0529]
[0530]
[0531]
[0532]
[0533]
[0534]
[0535]
[0536]
[0537]
[0538]
[0539]
[0540]
[0541]
[0542]
[0543]
[0544]
[0545]
[0546]
[0547]
[0548]
[0549]
[0550]
[0551]
[0552]
[0553]
[0554]
[0555]
[0556]
[0557]
[0558]
[0559]
[0560]
[0561]
[0562]
[0563]
[0564]
[0565]
[0566]
[0567]
[0568]
[0569]
[0570]
[0571]
[0572]
[0573]
[0574]
[0575]
[0576]
[0577]
[0578]
[0579]
[0580]
[0581]
[0582]
[0583]
[0584]
[0585]
[0586]
[0587]
[0588]
[0589]
[0590]
[0591]
[0592]
[0593]
[0594]
[0595]
[0596]
[0597]
[0598]
[0599]
[0600]
[0601]
[0602]
[0603]
[0604]
[0605]
[0606]
[0607]
[0608]
[0609]
[0610]
[0611]
[0612]
[0613]
[0614]
[0615]
[0616]
[0617]
[0618]
[0619]
[0620]
[0621]
[0622]
[0623]
[0624]
[0625]
[0626]
[0627]
[0628]
[0629]
[0630]
[0631]
[0632]
[0633]
[0634]
[0635]
[0636]
[0637]
[0638]
[0639]
[0640]
[0641]
[0642]
[0643]
[0644]
[0645]
[0646]
[0647]
[0648]
[0649]
[0650]
[0651]
[0652]
[0653]
[0654]
[0655]
[0656]
[0657]
[0658]
[0659]
[0660]
[0661]
[0662]
[0663]
[0664]
[0665]
[0666]
[0667]
[0668]
[0669]
[0670]
[0671]
[0672]
[0673]
[0674]
[0675]
[0676]
[0677]
[0678]
[0679]
[0680]
[0681]
[0682]
[0683]
[0684]
[0685]
[0686]
[0687]
[0688]
[0689]
[0690]
[0691]
[0692]
[0693]
[0694]
[0695]
[0696]
[0697]
[0698]
[0699]
[0700]
[0701]
[0702]
[0703]
[0704]
[0705]
[0706]
[0707]
[0708]
[0709]
[0710]
[0711]
[0712]
[0713]
[0714]
[0715]
[0716]
[0717]
[0718]
[0719]
[0720]
[0721]
[0722]
[0723]
[0724]
[0725]
[0726]
[0727]
[0728]
[0729]
[0730]
[0731]
[0732]
[0733]
[0734]
[0735]
[0736]
[0737]
[0738]
[0739]
[0740]
[0741]
[0742]
[0743]
[0744]
[0745]
[0746]
[0747]
[0748]
[0749]
[0750]
[0751]
[0752]
[0753]
[0754]
[0755]
[0756]
[0757]
[0758]
[0759]
[0760]
[0761]
[0762]
[0763]
[0764]
[0765]
[0766]
[0767]
[0768]
[0769]
[0770]
[0771]
[0772]
[0773]
[0774]
[0775]
[0776]
[0777]
[0778]
[0779]
[0780]
[0781]
[0782]
[0783]
[0784]
[0785]
[0786]
[0787]
[0788]
[0789]
[0790]
[0791]
[0792]
[0793]
[0794]
[0795]
[0796]
[0797]
[0798]
[0799]
[0800]
[0801]
[0802]
[0803]
[0804]
[0805]
[0806]
[0807]
[0808]
[0809]
[0810]
[0811]
[0812]
[0813]
[0814]
[0815]
[0816]
[0817]
[0818]
[0819]
[0820]
[0821]
[0822]
[0823]
[0824]
[0825]
[0826]
[0827]
[0828]
[0829]
[0830]
[0831]
[0832]
[0833]
[0834]
[0835]
[0836]
[0837]
[0838]
[0839]
[0840]
[0841]
[0842]
[0843]
[0844]
[0845]
[0846]
[0847]
[0848]
[0849]
[0850]
[0851]
[0852]
[0853]
[0854]
[0855]
[0856]
[0857]
[0858]
[0859]
[0860]
[0861]
[0862]
[0863]
[0864]
[0865]
[0866]
[0867]
[0868]
[0869]
[0870]
[0871]
[0872]
[0873]
[0874]
[0875]
[0876]
[0877]
[0878]
[0879]
[0880]
[0881]
[0882]
[0883]
[0884]
[0885]
[0886]
[0887]
[0888]
[0889]
[0890]
[0891]
[0892]
[0893]
[0894]
[0895]
[0896]
[0897]
[0898]
[0899]
[0900]
[0901]
[0902]
[0903]
[0904]
[0905]
[0906]
[0907]
[0908]
[0909]
[0910]
[0911]
[0912]
[0913]
[0914]
[0915]
[0916]
[0917]
[0918]
[0919]
[0920]
[0921]
[0922]
[0923]
[0924]
[0925]
[0926]
[0927]
[0928]
[0929]
[0930]
[0931]
[0932]
[0933]
[0934]
[0935]
[0936]
[0937]
[0938]
[0939]
[0940]
[0941]
[0942]
[0943]
[0944]
[0945]
[0946]
[0947]
[0948]
[0949]
[0950]
[0951]
[0952]
[0953]
[0954]
[0955]
[0956]
[0957]
[0958]
[0959]
[0960]
[0961]
[0962]
[0963]
[0964]
[0965]
[0966]
[0967]
[0968]
[0969]
[0970]
[0971]
[0972]
[0973]
[0974]
[0975]
[0976]
[0977]
[0978]
[0979]
[0980]
[0981]
[0982]
[0983]
[0984]
[0985]
[0986]
[0987]
[0988]
[0989]
[0990]
[0991]
[0992]
[0993]
[0994]
[0995]
[0996]
[0997]
[0998]
[0999]
[1000]
[1001]
[1002]
[1003]
[1004]
[1005]
[1006]
[1007]
[1008]
[1009]
[1010]
[1011]
[1012]
[1013]
[1014]
[1015]
[1016]
[1017]
[1018]
[1019]
[1020]
[1021]
[1022]
[1023]
[1024]
[1025]
[1026]
[1027]
[1028]
[1029]
[1030]
[1031]
[1032]
[1033]
[1034]
[1035]
[1036]
[1037]
[1038]
[1039]
[1040]
[1041]
[1042]
[1043]
[1044]
[1045]
[1046]
[1047]
[1048]
[1049]
[1050]
[1051]
[1052]
[1053]
[1054]
[1055]
[1056]
[1057]
[1058]
[1059]
[1060]
[1061]
[1062]
[1063]
[1064]
[1065]
[1066]
[1067]
[1068]
[1069]
[1070]
[1071]
[1072]
[1073]
[1074]
[1075]
[1076]
[1077]
[1078]
[1079]
[1080]
[1081]
[1082]
[1083]
[1084]
[1085]
[1086]
[1087]
[1088]
[1089]
[1090]
[1091]
[1092]
[1093]
[1094]
[1095]
[1096]
[1097]
[1098]
[1099]
[1100]
[1101]
[1102]
[1103]
[1104]
[1105]
[1106]
[1107]
[1108]
[1109]
[1110]
[1111]
[1112]
[1113]
[1114]
[1115]
[1116]
[1117]
[1118]
[1119]
[1120]
[1121]
[1122]
[1123]
[1124]
[1125]
[1126]
[1127]
[1128]
[1129]
[1130]
[1131]
[1132]
[1133]
[1134]
[1135]
[1136]
[1137]
[1138]
[1139]
[1140]
[1141]
[1142]
[1143]
[1144]
[1145]
[1146]
[1147]
[1148]
[1149]
[1150]
[1151]
[1152]
[1153]
[1154]
[1155]
[1156]
[1157]
[1158]
[1159]
[1160]
[1161]
[1162]
[1163]
[1164]
[1165]
[1166]
[1167]
[1168]
[1169]
[1170]
[1171]
[1172]
[1173]
[1174]
[1175]
[1176]
[1177]
[1178]
[1179]
[1180]
[1181]
[1182]
[1183]
[1184]
[1185]
[1186]
[1187]
[1188]
[1189]
[1190]
[1191]
[1192]
[1193]
[1194]
[1195]
[1196]
[1197]
[1198]
[1199]
[1200]
[1201]
[1202]
[1203]
[1204]
[1205]
[1206]
[1207]
[1208]
[1209]
[1210]
[1211]
[1212]
[1213]
[1214]
[1215]
[1216]
[1217]
[1218]
[1219]
[1220]
[1221]
[1222]
[1223]
[1224]
[1225]
[1226]
[1227]
[1228]
[1229]
[1230]
[1231]
[1232]
[1233]
[1234]
[1235]
[1236]
[1237]
[1238]
[1239]
[1240]
[1241]
[1242]
[1243]
[1244]
[1245]
[1246]
[1247]
[1248]
[1249]
[1250]
[1251]
[1252]
[1253]
[1254]
[1255]
[1256]
[1257]
[1258]
[1259]
[1260]
[1261]
[1262]
[1263]
[1264]
[1265]
[1266]
[1267]
[1268]
[1269]
[1270]
[1271]
[1272]
[1273]
[1274]
[1275]
[1276]
[1277]
[1278]
[1279]
[1280]
[1281]
[1282]
[1283]
[1284]
[1285]
[1286]
[1287]
[1288]
[1289]
[1290]
[1291]
[1292]
[1293]
[1294]
[1295]
[1296]
[1297]
[1298]
[1299]
[1300]
[1301]
[1302]
[1303]
[1304]
[1305]
[1306]
[1307]
[1308]
[1309]
[1310]
[1311]
[1312]
[1313]
[1314]
[1315]
[1316]
[1317]
[1318]
[1319]
[1320]
[1321]
[1322]
[1323]
[1324]
[1325]
[1326]
[1327]
[1328]
[1329]
[1330]
[1331]
[1332]
[1333]
[1334]
[1335]
[1336]
[1337]
[1338]
[1339]
[1340]
[1341]
[1342]
[1343]
[1344]
[1345]
[1346]
[1347]
[1348]
[1349]
[1350]
[1351]
[1352]
[1353]
[1354]
[1355]
[1356]
[1357]
[1358]
[1359]
[1360]
[1361]
[1362]
[1363]
[1364]
[1365]
[1366]
[1367]
[1368]
[1369]
[1370]
[1371]
[1372]
[1373]
[1374]
[1375]
[1376]
[1377]
[1378]
[1379]
[1380]
[1381]
[1382]
[1383]
[1384]
[1385]
[1386]
[1387]
[1388]
[1389]
[1390]
[1391]
[1392]
[1393]
[1394]
[1395]
[1396]
[1397]
[1398]
[1399]
[1400]
[1401]
[1402]
[1403]
[1404]
[1405]
[1406]
[1407]
[1408]
[1409]
[1410]
[1411]
[1412]
[1413]
[1414]
[1415]
[1416]
[1417]
[1418]
[1419]
[1420]
[1421]
[1422]
[1423]
[1424]
[1425]
[1426]
[1427]
[1428]
[1429]
[1430]
[1431]
[1432]
[1433]
[1434]
[1435]
[1436]
[1437]
[1438]
[1439]
[1440]
[1441]
[1442]
[1443]
[1444]
[1445]
[1446]
[1447]
[1448]
[1449]
[1450]
[1451]
[1452]
[1453]
[1454]
[1455]
[1456]
[1457]
[1458]
[1459]
[1460]
[1461]
[1462]
[1463]
[1464]
[1465]
[1466]
[1467]
[1468]
[1469]
[1470]
[1471]
[1472]
[1473]
[1474]
[1475]
[1476]
[1477]
[1478]
[1479]
[1480]
[1481]
[1482]
[1483]
[1484]
[1485]
[1486]
[1487]
[1488]
[1489]
[1490]
[1491]
[1492]
[1493]
[1494]
[1495]
[1496]
[1497]
[1498]
[1499]
[1500]
[1501]
[1502]
[1503]
[1504]
[1505]
[1506]
[1507]
[1508]
[1509]
[1510]
[1511]
[1512]
[1513]
[1514]
[1515]
[1516]
[1517]
[1518]
[1519]
[1520]
[1521]
[1522]
[1523]
[1524]
[1525]
[1526]
[1527]
[1528]
[1529]
[1530]
[1531]
[1532]
[1533]
[1534]
[1535]
[1536]
[1537]
[1538]
[1539]
[1540]
[1541]
[1542]
[1543]
[1544]
[1545]
[1546]
[1547]
[1548]
[1549]
[1550]
[1551]
[1552]
[1553]
[1554]
[1555]
[1556]
[1557]
[1558]
[1559]
[1560]
[1561]
[1562]
[1563]
[1564]
[1565]
[1566]
[1567]
[1568]
[1569]
[1570]
[1571]
[1572]
[1573]
[1574]
[1575]
[1576]
[1577]
[1578]
[1579]
[1580]
[1581]
[1582]
[1583]
[1584]
[1585]
[1586]
[1587]
[1588]
[1589]
[1590]
[1591]
[1592]
[1593]
[1594]
[1595]
[1596]
[1597]
[1598]
[1599]
[1600]
[1601]
[1602]
[1603]
[1604]
[1605]
[1606]
[1607]
[1608]
[1609]
[1610]
[1611]
[1612]
[1613]
[1614]
[1615]
[1616]
[1617]
[1618]
[1619]
[1620]
[1621]
[1622]
[1623]
[1624]
[1625]
[1626]
[1627]
[1628]
[1629]
[1630]
[1631]
[1632]
[1633]
[1634]
[1635]
[1636]
[1637]
[1638]
[1639]
[1640]
[1641]
[1642]
[1643]
[1644]
[1645]
[1646]
[1647]
[1648]
[1649]
[1650]
[1651]
[1652]
[1653]
[1654]
[1655]
[1656]
[1657]
[1658]
[1659]
[1660]
[1661]
[1662]
[1663]
[1664]
[1665]
[1666]
[1667]
[1668]
[1669]
[1670]
[1671]
[1672]
[1673]
[1674]
[1675]
[1676]
[1677]
[1678]
[1679]
[1680]
[1681]
[1682]
[1683]
[1684]
[1685]
[1686]
[1687]
[1688]
[1689]
[1690]
[1691]
[1692]
[1693]
[1694]
[1695]
[1696]
[1697]
[1698]
[1699]
[1700]
[1701]
[1702]
[1703]
[1704]
[1705]
[1706]
[1707]
[1708]
[1709]
[1710]
[1711]
[1712]
[1713]
[1714]
[1715]
[1716]
[1717]
[1718]
[1719]
[1720]
[1721]
[1722]
[1723]
[1724]
[1725]
[1726]
[1727]
[1728]
[1729]
[1730]
[1731]
[1732]
[1733]
[1734]
[1735]
[1736]
[1737]
[1738]
[1739]
[1740]
[1741]
[1742]
[1743]
[1744]
[1745]
[1746]
[1747]
[1748]
[1749]
[1750]
[1751]
[1752]
[1753]
[1754]
[1755]
[1756]
[1757]
[1758]
[1759]
[1760]
[1761]
[1762]
[1763]
[1764]
[1765]
[1766]
[1767]
[1768]
[1769]
[1770]
[1771]
[1772]
[1773]
[1774]
[1775]
[1776]
[1777]
[1778]
[1779]
[1780]
[1781]
[1782]
[1783]
[1784]
[1785]
[1786]
[1787]
[1788]
[1789]
[1790]
[1791]
[1792]
[1793]
[1794]
[1795]
[1796]
[1797]
[1798]
[1799]
[1800]
[1801]
[1802]
[1803]
[1804]
[1805]
[1806]
[1807]
[1808]
[1809]
[1810]
[1811]
[1812]
[1813]
[1814]
[1815]
[1816]
[1817]
[1818]
[1819]
[1820]
[1821]
[1822]
[1823]
[1824]
[1825]
[1826]
[1827]
[1828]
[1829]
[1830]
[1831]
[1832]
[1833]
[1834]
[1835]
[1836]
[1837]
[1838]
[1839]
[1840]
[1841]
[1842]
[1843]
[1844]
[1845]
[1846]
[1847]
[1848]
[1849]
[1850]
[1851]
[1852]
[1853]
[1854]
[1855]
[1856]
[1857]
[1858]
[1859]
[1860]
[1861]
[1862]
[1863]
[1864]
[1865]
[1866]
[1867]
[1868]
[1869]
[1870]
[1871]
[1872]
[1873]
[1874]
[1875]
[1876]
[1877]
[1878]
[1879]
[1880]
[1881]
[1882]
[1883]
[1884]
[1885]
[1886]
[1887]
[1888]
[1889]
[1890]
[1891]
[1892]
[1893]
[1894]
[1895]
[1896]
[1897]
[1898]
[1899]
[1900]
[1901]
[1902]
[1903]
[1904]
[1905]
[1906]
[1907]
[1908]
[1909]
[1910]
[1911]
[1912]
[1913]
[1914]
[1915]
[1916]
[1917]
[1918]
[1919]
[1920]
[1921]
[1922]
[1923]
[1924]
[1925]
[1926]
[1927]
[1928]
[1929]
[1930]
[1931]
[1932]
[1933]
[1934]
[1935]
[1936]
[1937]
[1938]
[1939]
[1940]
[1941]
[1942]
[1943]
[1944]
[1945]
[1946]
[1947]
[1948]
[1949]
[1950]
[1951]
[1952]
[1953]
[1954]
[1955]
[1956]
[1957]
[1958]
[1959]
[1960]
[1961]
[1962]
[1963]
[1964]
[1965]
[1966]
[1967]
[1968]
[1969]
[1970]
[1971]
[1972]
[1973]
[1974]
[1975]
[1976]
[1977]
[1978]
[1979]
[1980]
[1981]
[1982]
[1983]
[1984]
[1985]
[1986]
[1987]
[1988]
[1989]
[1990]
[1991]
[1992]
[1993]
[1994]
[1995]
[1996]
[1997]
[1998]
[1999]
[2000]
[2001]
[2002]
[2003]
[2004]
[2005]
[2006]
[2007]
[2008]
[2009]
[2010]
[2011]
[2012]
[2013]
[2014]
[2015]
[2016]
[2017]
[2018]
[2019]
[2020]
[2021]
[2022]
[2023]
[2024]
[2025]
[2026]
[2027]
[2028]
[2029]
[2030]
[2031]
[2032]
[2033]
[2034]
[2035]
[2036]
[2037]
[2038]
[2039]
[2040]
[2041]
[2042]
[2043]
[2044]
[2045]
[2046]
[2047]
[2048]
[2049]
[2050]
[2051]
[2052]
[2053]
[2054]
[2055]
[2056]
[2057]
[2058]
[2059]
[2060]
[2061]
[2062]
[2063]
[2064]
[2065]
[2066]
[2067]
[2068]
[2069]
[2070]
[2071]
[2072]
[2073]
[2074]
[2075]
[2076]
[2077]
[2078]
[2079]
[2080]
[2081]
[2082]
[2083]
[2084]
[2085]
[2086]
[2087]
[2088]
[2089]
[2090]
[2091]
[2092]
[2093]
[2094]
[2095]
[2096]
[2097]
[2098]
[2099]
[2100]
[2101]
[2102]
[2103]
[2104]
[2105]
[2106]
[2107]
[2108]
[2109]
[2110]
[2111]
[2112]
[2113]
[2114]
[2115]
[2116]
[2117]
[2118]
[2119]
[2120]
[2121]
[2122]
[2123]
[2124]
[2125]
[2126]
[2127]
[2128]
[2129]
[2130]
[2131]
[2132]
[2133]
[2134]
[2135]
[2136]
[2137]
[2138]
[2139]
[2140]
[2141]
[2142]
[2143]
[2144]
[2145]
[2146]
[2147]
[2148]
[2149]
[2150]
[2151]
[2152]
[2153]
[2154]
[2155]
[2156]
[2157]
[2158]
[2159]
[2160]
[2161]
[2162]
[2163]
[2164]
[2165]
[2166]
[2167]
[2168]
[2169]
[2170]
[2171]
[2172]
[2173]
[2174]
[2175]
[2176]
[2177]
[2178]
[2179]
[2180]
[2181]
[2182]
[2183]
[2184]
[2185]
[2186]
[2187]
[2188]
[2189]
[2190]
[2191]
[2192]
[2193]
[2194]
[2195]
[2196]
[2197]
[2198]
[2199]
[2200]
[2201]
[2202]
[2203]
[2204]
[2205]
[2206]
[2207]
[2208]
[2209]
[2210]
[2211]
[2212]
[2213]
[2214]
[2215]
[2216]
[2217]
[2218]
[2219]
[2220]
[2221]
[2222]
[2223]
[2224]
[2225]
[2226]
[2227]
[2228]
[2229]
[2230]
[2231]
[2232]
[2233]
[2234]
[2235]
[2236]
[2237]
[2238]
[2239]
[2240]
[2241]
[2242]
[2243]
[2244]
[2245]
[2246]
[2247]
[2248]
[2249]
[2250]
[2251]
[2252]
[2253]
[2254]
[2255]
[2256]
[2257]
[2258]
[2259]
[2260]
[2261]
[2262]
[2263]
[2264]
[2265]
[2266]
[2267]
[2268]
[2269]
[2270]
[2271]
[2272]
[2273]
[2274]
[2275]
[2276]
[2277]
[2278]
[2279]
[2280]
[2281]
[2282]
[2283]
[2284]
[2285]
[2286]
[2287]
[2288]
[2289]
[2290]
[2291]
[2292]
[2293]
[2294]
[2295]
[2296]
[2297]
[2298]
[2299]
[2300]
[2301]
[2302]
[2303]
[2304]
[2305]
[2306]
[2307]
[2308]
[2309]
[2310]
[2311]
[2312]
[2313]
[2314]
[2315]
[2316]
[2317]
[2318]
[2319]
[2320]
[2321]
[2322]
[2323]
[2324]
[2325]
[2326]
[2327]
[2328]
[2329]
[2330]
[2331]
[2332]
[2333]
[2334]
[2335]
[2336]
[2337]
[2338]
[2339]
[2340]
[2341]
[2342]
[2343]
[2344]
[2345]
[2346]
[2347]
[2348]
[2349]
[2350]
[2351]
[2352]
[2353]
[2354]
[2355]
[2356]
[2357]
[2358]
[2359]
[2360]
[2361]
[2362]
[2363]
[2364]
[2365]
[2366]
[2367]
[2368]
[2369]
[2370]
[2371]
[2372]
[2373]
[2374]
[2375]
[2376]
[2377]
[2378]
[2379]
[2380]
[2381]
[2382]
[2383]
[2384]
[2385]
[2386]
[2387]
[2388]
[2389]
[2390]
[2391]
[2392]
[2393]
[2394]
[2395]
[2396]
[2397]
[2398]
[2399]
[2400]
[2401]
[2402]
[2403]
[2404]
[2405]
[2406]
[2407]
[2408]
[2409]
[2410]
[2411]
[2412]
[2413]
[2414]
[2415]
[2416]
[2417]
[2418]
[2419]
[2420]
[2421]
[2422]
[2423]
[2424]
[2425]
[2426]
[2427]
[2428]
[2429]
[2430]
[2431]
[2432]
[2433]
[2434]
[2435]
[2436]
[2437]
[2438]
[2439]
[2440]
[2441]
[2442]
[2443]
[2444]
[2445]
[2446]
[2447]
[2448]
[2449]
[2450]
[2451]
[2452]
[2453]
[2454]
[2455]
[2456]
[2457]
[2458]
[2459]
[2460]
[2461]
[2462]
[2463]
[2464]
[2465]
[2466]
[2467]
[2468]
[2469]
[2470]
[2471]
[2472]
[2473]
[2474]
[2475]
[2476]
[2477]
[2478]
[2479]
[2480]
[2481]
[2482]
[2483]
[2484]
[2485]
[2486]
[2487]
[2488]
[2489]
[2490]
[2491]
[2492]
[2493]
[2494]
[2495]
[2496]
[2497]
[2498]
[2499]
[2500]
[2501]
[2502]
[2503]
[2504]
[2505]
[2506]
[2507]
[2508]
[2509]
[2510]
[2511]
[2512]
[2513]
[2514]
[2515]
[2516]
[2517]
[2518]
[2519]
[2520]
[2521]
[2522]
[2523]
[2524]
[2525]
[2526]
[2527]
[2528]
[2529]
[2530]
[2531]
[2532]
[2533]
[2534]
[2535]
[2536]
[2537]
[2538]
[2539]
[2540]
[2541]
[2542]
[2543]
[2544]
[2545]
[2546]
[2547]
[2548]
[2549]
[2550]
[2551]
[2552]
[2553]
[2554]
[2555]
[2556]
[2557]
[2558]
[2559]
[2560]
[2561]
[2562]
[2563]
[2564]
[2565]
[2566]
[2567]
[2568]
[2569]
[2570]
[2571]
[2572]
[2573]
[2574]
[2575]
[2576]
[2577]
[2578]
[2579]
[2580]
[2581]
[2582]
[2583]
[2584]
[2585]
[2586]
[2587]
[2588]
[2589]
[2590]
[2591]
[2592]
[2593]
[2594]
[2595]
[2596]
[2597]
[2598]
[2599]
[2600]
[2601]
[2602]
[2603]
[2604]
[2605]
[2606]
[2607]
[2608]
[2609]
[2610]
[2611]
[2612]
[2613]
[2614]
[2615]
[2616]
[2617]
[2618]
[2619]
[2620]
[2621]
[2622]
[2623]
[2624]
[2625]
[2626]
[2627]
[2628]
[2629]
[2630]
[2631]
[2632]
[2633]
[2634]
[2635]
[2636]
[2637]
[2638]
[2639]
[2640]
[2641]
[2642]
[2643]
[2644]
[2645]
[2646]
[2647]
[2648]
[2649]
[2650]
[2651]
[2652]
[2653]
[2654]
[2655]
[2656]
[2657]
[2658]
[2659]
[2660]
[2661]
[2662]
[2663]
[2664]
[2665]
[2666]
[2667]
[2668]
[2669]
[2670]
[2671]
[2672]
[2673]
[2674]
[2675]
[2676]
[2677]
[2678]
[2679]
[2680]
[2681]
[2682]
[2683]
[2684]
[2685]
[2686]
[2687]
[2688]
[2689]
[2690]
[2691]
[2692]
[2693]
[2694]
[2695]
[2696]
[2697]
[2698]
[2699]
[2700]
[2701]
[2702]
[2703]
[2704]
[2705]
[2706]
[2707]
[2708]
[2709]
[2710]
[2711]
[2712]
[2713]
[2714]
[2715]
[2716]
[2717]
[2718]
[2719]
[2720]
[2721]
[2722]
[2723]
[2724]
[2725]
[2726]
[2727]
[2728]
[2729]
[2730]
[2731]
[2732]
[2733]
[2734]
[2735]
[2736]
[2737]
[2738]
[2739]
[2740]
[2741]
[2742]
[2743]
[2744]
[2745]
[2746]
[2747]
[2748]
[2749]
[2750]
[2751]
[2752]
[2753]
[2754]
[2755]
[2756]
[2757]
[2758]
[2759]
[2760]
[2761]
[2762]
[2763]
[2764]
[2765]
[2766]
[2767]
[2768]
[2769]
[2770]
[2771]
[2772]
[2773]
[2774]
[2775]
[2776]
[2777]
[2778]
[2779]
[2780]
[2781]
[2782]
[2783]
[2784]
[2785]
[2786]
[2787]
[2788]
[2789]
[2790]
[2791]
[2792]
[2793]
[2794]
[2795]
[2796]
[2797]
[2798]
[2799]
[2800]
[2801]
[2802]
[2803]
[2804]
[2805]
[2806]
[2807]
[2808]
[2809]
[2810]
[2811]
[2812]
[2813]
[2814]
[2815]
[2816]
[2817]
[2818]
[2819]
[2820]
[2821]
[2822]
[2823]
[2824]
[2825]
[2826]
[2827]
[2828]
[2829]
[2830]
[2831]
[2832]
[2833]
[2834]
[2835]
[2836]
[2837]
[2838]
[2839]
[2840]
[2841]
[2842]
[2843]
[2844]
[2845]
[2846]
[2847]
[2848]
[2849]
[2850]
[2851]
[2852]
[2853]
[2854]
[2855]
[2856]
[2857]
[2858]
[2859]
[2860]
[2861]
[2862]
[2863]
[2864]
[2865]
[2866]
[2867]
[2868]
[2869]
[2870]
[2871]
[2872]
[2873]
[2874]
[2875]
[2876]
[2877]
[2878]
[2879]
[2880]
[2881]
[2882]
[2883]
[2884]
[2885]
[2886]
[2887]
[2888]
[2889]
[2890]
[2891]
[2892]
[2893]
[2894]
[2895]
[2896]
[2897]
[2898]
[2899]
[2900]
[2901]
[2902]
[2903]
[2904]
[2905]
[2906]
[2907]
[2908]
[2909]
[2910]
[2911]
[2912]
[2913]
[2914]
[2915]
[2916]
[2917]
[2918]
[2919]
[2920]
[2921]
[2922]
[2923]
[2924]
[2925]
[2926]
[2927]
[2928]
[2929]
[2930]
[2931]
[2932]
[2933]
[2934]
[2935]
[2936]
[2937]
[2938]
[2939]
[2940]
[2941]
[2942]
[2943]
[2944]
[2945]
[2946]
[2947]
[2948]
[2949]
[2950]
[2951]
[2952]
[2953]
[2954]
[2955]
[2956]
[2957]
[2958]
[2959]
[2960]
[2961]
[2962]
[2963]
[2964]
[2965]
[2966]
[2967]
[2968]
[2969]
[2970]
[2971]
[2972]
[2973]
[2974]
[2975]
[2976]
[2977]
[2978]
[2979]
[2980]
[2981]
[2982]
[2983]
[2984]
[2985]
[2986]
[2987]
[2988]
[2989]
[2990]
[2991]
[2992]
[2993]
[2994]
[2995]
[2996]
[2997]
[2998]
[2999]
[3000]
[3001]
[3002]
[3003]
[3004]
[3005]
[3006]
[3007]
[3008]
[3009]
[3010]
[3011]
[3012]
[3013]
[3014]
[3015]
[3016]
[3017]
[3018]
[3019]
[3020]
[3021]
[3022]
[3023]
[3024]
[3025]
[3026]
[3027]
[3028]
[3029]
[3030]
[3031]
[3032]
[3033]
[3034]
[3035]
[3036]
[3037]
[3038]
[3039]
[3040]
[3041]
[3042]
[3043]
[3044]
[3045]
[3046]
[3047]
[3048]
[3049]
[3050]
[3051]
[3052]
[3053]
[3054]
[3055]
[3056]
[3057]
[3058]
[3059]
[3060]
[3061]
[3062]
[3063]
[3064]
[3065]
[3066]
[3067]
[3068]
[3069]
[3070]
[3071]
[3072]
[3073]
[3074]
[3075]
[3076]
[3077]
[3078]
[3079]
[3080]
[3081]
[3082]
[3083]
[3084]
[3085]
[3086]
[3087]
[3088]
[3089]
[3090]
[3091]
[3092]
[3093]
[3094]
[3095]
[3096]
[3097]
[3098]
[3099]
[3100]
[3101]
[3102]
[3103]
[3104]
[3105]
[3106]
[3107]
[3108]
[3109]
[3110]
[3111]
[3112]
[3113]
[3114]
[3115]
[3116]
[3117]
[3118]
[3119]
[3120]
[3121]
[3122]
[3123]
[3124]
[3125]
[3126]
[3127]
[3128]
[3129]
[3130]
[3131]
[3132]
[3133]
[3134]
[3135]
[3136]
[3137]
[3138]
[3139]
[3140]
[3141]
[3142]
[3143]
[3144]
[3145]
[3146]
[3147]
[3148]
[3149]
[3150]
[3151]
[3152]
[3153]
[3154]
[3155]
[3156]
[3157]
[3158]
[3159]
[3160]
[3161]
[3162]
[3163]
[3164]
[3165]
[3166]
[3167]
[3168]
[3169]
[3170]
[3171]
[3172]
[3173]
[3174]
[3175]
[3176]
[3177]
[3178]
[3179]
[3180]
[3181]
[3182]
[3183]
[3184]
[3185]
[3186]
[3187]
[3188]
[3189]
[3190]
[3191]
[3192]
[3193]
[3194]
[3195]
[3196]
[3197]
[3198]
[3199]
[3200]
[3201]
[3202]
[3203]
[3204]
[3205]
[3206]
[3207]
[3208]
[3209]
[3210]
[3211]
[3212]
[3213]
[3214]
[3215]
[3216]
[3217]
[3218]
[3219]
[3220]
[3221]
[3222]
[3223]
[3224]
[3225]
[3226]
[3227]
[3228]
[3229]
[3230]
[3231]
[3232]
[3233]
[3234]
[3235]
[3236]
[3237]
[3238]
[3239]
[3240]
[3241]
[3242]
[3243]
[3244]
[3245]
[3246]
[3247]
[3248]
[3249]
[3250]
[3251]
[3252]
[3253]
[3254]
[3255]
[3256]
[3257]
[3258]
[3259]
[3260]
[3261]
[3262]
[3263]
[3264]
[3265]
[3266]
[3267]
[3268]
[3269]
[3270]
[3271]
[3272]
[3273]
[3274]
[3275]
[3276]
[3277]
[3278]
[3279]
[3280]
[3281]
[3282]
[3283]
[3284]
[3285]
[3286]
[3287]
[3288]
[3289]
[3290]
[3291]
[3292]
[3293]
[3294]
[3295]
[3296]
[3297]
[3298]
[3299]
[3300]
[3301]
[3302]
[3303]
[3304]
[3305]
[3306]
[3307]
[3308]
[3309]
[3310]
[3311]
[3312]
[3313]
[3314]
[3315]
[3316]
[3317]
[3318]
[3319]
[3320]
[3321]
[3322]
[3323]
[3324]
[3325]
[3326]
[3327]
[3328]
[3329]
[3330]
[3331]
[3332]
[3333]
[3334]
[3335]
[3336]
[3337]
[3338]
[3339]
[3340]
[3341]
[3342]
[3343]
[3344]
[3345]
[3346]
[3347]
[3348]
[3349]
[3350]
[3351]
[3352]
[3353]
[3354]
[3355]
[3356]
[3357]
[3358]
[3359]
[3360]
[3361]
[3362]
[3363]
[3364]
[3365]
[3366]
[3367]
[3368]
[3369]
[3370]
[3371]
[3372]
[3373]
[3374]
[3375]
[3376]
[3377]
[3378]
[3379]
[3380]
[3381]
[3382]
[3383]
[3384]
[3385]
[3386]
[3387]
[3388]
[3389]
[3390]
[3391]
[3392]
[3393]
[3394]
[3395]
[3396]
[3397]
[3398]
[3399]
[3400]
[3401]
[3402]
[3403]
[3404]
[3405]
[3406]
[3407]
[3408]
[3409]
[3410]
[3411]
[3412]
[3413]
[3414]
[3415]
[3416]
[3417]
[3418]
[3419]
[3420]
[3421]
[3422]
[3423]
[3424]
[3425]
[3426]
[3427]
[3428]
[3429]
[3430]
[3431]
[3432]
[3433]
[3434]
[3435]
[3436]
[3437]
[3438]
[3439]
[3440]
[3441]
[3442]
[3443]
[3444]
[3445]
[3446]
[3447]
[3448]
[3449]
[3450]
[3451]
[3452]
[3453]
[3454]
[3455]
[3456]
[3457]
[3458]
[3459]
[3460]
[3461]
[3462]
[3463]
[3464]
[3465]
[3466]
[3467]
[3468]
[3469]
[3470]
[3471]
[3472]
[3473]
[3474]
[3475]
[3476]
[3477]
[3478]
[3479]
[3480]
[3481]
[3482]
[3483]
[3484]
[3485]
[3486]
[3487]
[3488]
[3489]
[3490]
[3491]
[3492]
[3493]
[3494]
[3495]
[3496]
[3497]
[3498]
[3499]
[3500]
[3501]
[3502]
[3503]
[3504]
[3505]
[3506]
[3507]
[3508]
[3509]
[3510]
[3511]
[3512]
[3513]
[3514]
[3515]
[3516]
[3517]
[3518]
[3519]
[3520]
[3521]
[3522]
[3523]
[3524]
[3525]
[3526]
[3527]
[3528]
[3529]
[3530]
[3531]
[3532]
[3533]
[3534]
[3535]
[3536]
[3537]
[3538]
[3539]
[3540]
[3541]
[3542]
[3543]
[3544]
[3545]
[3546]
[3547]
[3548]
[3549]
[3550]
[3551]
[3552]
[3553]
[3554]
[3555]
[3556]
[3557]
[3558]
[3559]
[3560]
[3561]
[3562]
[3563]
[3564]
[3565]
[3566]
[3567]
[3568]
[3569]
[3570]
[3571]
[3572]
[3573]
[3574]
[3575]
[3576]
[3577]
[3578]
[3579]
[3580]
[3581]
[3582]
[3583]
[3584]
[3585]
[3586]
[3587]
[3588]
[3589]
[3590]
[3591]
[3592]
[3593]
[3594]
[3595]
[3596]
[3597]
[3598]
[3599]
[3600]
[3601]
[3602]
[3603]
[3604]
[3605]
[3606]
[3607]
[3608]
[3609]
[3610]
[3611]
[3612]
[3613]
[3614]
[3615]
[3616]
[3617]
[3618]
[3619]
[3620]
[3621]
[3622]
[3623]
[3624]
[3625]
[3626]
[3627]
[3628]
[3629]
[3630]
[3631]
[3632]
[3633]
[3634]
[3635]
[3636]
[3637]
[3638]
[3639]
[3640]
[3641]
[3642]
[3643]
[3644]
[3645]
[3646]
[3647]
[3648]
[3649]
[3650]
[3651]
[3652]
[3653]
[3654]
[3655]
[3656]
[3657]
[3658]
[3659]
[3660]
[3661]
[3662]
[3663]
[3664]
[3665]
[3666]
[3667]
[3668]
[3669]
[3670]
[3671]
[3672]
[3673]
[3674]
[3675]
[3676]
[3677]
[3678]
[3679]
[3680]
[3681]
[3682]
[3683]
[3684]
[3685]
[3686]
[3687]
[3688]
[3689]
[3690]
[3691]
[3692]
[3693]
[3694]
[3695]
[3696]
[3697]
[3698]
[3699]
[3700]
[3701]
[3702]
[3703]
[3704]
[3705]
[3706]
[3707]
[3708]
[3709]
[3710]
[3711]
[3712]
[3713]
[3714]
[3715]
[3716]
[3717]
[3718]
[3719]
[3720]
[3721]
[3722]
[3723]
[3724]
[3725]
[3726]
[3727]
[3728]
[3729]
[3730]
[3731]
[3732]
[3733]
[3734]
[3735]
[3736]
[3737]
[3738]
[3739]
[3740]
[3741]
[3742]
[3743]
[3744]
[3745]
[3746]
[3747]
[3748]
[3749]
[3750]
[3751]
[3752]
[3753]
[3754]
[3755]
[3756]
[3757]
[3758]
[3759]
[3760]
[3761]
[3762]
[3763]
[3764]
[3765]
[3766]
[3767]
[3768]
[3769]
[3770]
[3771]
[3772]
[3773]
[3774]
[3775]
[3776]
[3777]
[3778]
[3779]
[3780]
[3781]
[3782]
[3783]
[3784]
[3785]
[3786]
[3787]
[3788]
[3789]
[3790]
[3791]
[3792]
[3793]
[3794]
[3795]
[3796]
[3797]
[3798]
[3799]
[3800]
[3801]
[3802]
[3803]
[3804]
[3805]
[3806]
[3807]
[3808]
[3809]
[3810]
[3811]
[3812]
[3813]
[3814]
[3815]
[3816]
[3817]
[3818]
[3819]
[3820]
[3821]
[3822]
[3823]
[3824]
[3825]
[3826]
[3827]
[3828]
[3829]
[3830]
[3831]
[3832]
[3833]
[3834]
[3835]
[3836]
[3837]
[3838]
[3839]
[3840]
[3841]
[3842]
[3843]
[3844]
[3845]
[3846]
[3847]
[3848]
[3849]
[3850]
[3851]
[3852]
[3853]
[3854]
[3855]
[3856]
[3857]
[3858]
[3859]
[3860]
[3861]
[3862]
[3863]
[3864]
[3865]
[3866]
[3867]
[3868]
[3869]
[3870]
[3871]
[3872]
[3873]
[3874]
[3875]
[3876]
[3877]
[3878]
[3879]
[3880]
[3881]
[3882]
[3883]
[3884]
[3885]
[3886]
[3887]
[3888]
[3889]
[3890]
[3891]
[3892]
[3893]
[3894]
[3895]
[3896]
[3897]
[3898]
[3899]
[3900]
[3901]
[3902]
[3903]
[3904]
[3905]
[3906]
[3907]
[3908]
[3909]
[3910]
[3911]
[3912]
[3913]
[3914]
[3915]
[3916]
[3917]
[3918]
[3919]
[3920]
[3921]
[3922]
[3923]
[3924]
[3925]
[3926]
[3927]
[3928]
[3929]
[3930]
[3931]
[3932]
[3933]
[3934]
[3935]
[3936]
[3937]
[3938]
[3939]
[3940]
[3941]
[3942]
[3943]
[3944]
[3945]
[3946]
[3947]
[3948]
[3949]
[3950]
[3951]
[3952]
[3953]
[3954]
[3955]
[3956]
[3957]
[3958]
[3959]
[3960]
[3961]
[3962]
[3963]
[3964]
[3965]
[3966]
[3967]
[3968]
[3969]
[3970]
[3971]
[3972]
[3973]
[3974]
[3975]
[3976]
[3977]
[3978]
[3979]
[3980]
[3981]
[3982]
[3983]
[3984]
[3985]
[3986]
[3987]
[3988]
[3989]
[3990]
[3991]
[3992]
[3993]
[3994]
[3995]
[3996]
[3997]
[3998]
[3999]
[4000]
[4001]
[4002]
[4003]
[4004]
[4005]
[4006]
[4007]
[4008]
[4009]
[4010]
[4011]
[4012]
[4013]
[4014]
[4015]
[4016]
[4017]
[4018]
[4019]
[4020]
[4021]
[4022]
[4023]
[4024]
[4025]
[4026]
[4027]
[4028]
[4029]
[4030]
[4031]
[4032]
[4033]
[4034]
[4035]
[4036]
[4037]
[4038]
[4039]
[4040]
[4041]
[4042]
[4043]
[4044]
[4045]
[4046]
[4047]
[4048]
[4049]
[4050]
[4051]
[4052]
[4053]
[4054]
[4055]
[4056]
[4057]
[4058]
[4059]
[4060]
[4061]
[4062]
[4063]
[4064]
[4065]
[4066]
[4067]
[4068]
[4069]
[4070]
[4071]
[4072]
[4073]
[4074]
[4075]
[4076]
[4077]
[4078]
[4079]
[4080]
[4081]
[4082]
[4083]
[4084]
[4085]
[4086]
[4087]
[4088]
[4089]
[4090]
[4091]
[4092]
[4093]
[4094]
[4095]
[4096]
[4097]
[4098]
[4099]
[4100]
[4101]
[4102]
[4103]
[4104]
[4105]
[4106]
[4107]
[4108]
[4109]
[4110]
[4111]
[4112]
[4113]
[4114]
[4115]
[4116]
[4117]
[4118]
[4119]
[4120]
[4121]
[4122]
[4123]
[4124]
[4125]
[4126]
[4127]
[4128]
[4129]
[4130]
[4131]
[4132]
[4133]
[4134]
[4135]
[4136]
[4137]
[4138]
[4139]
[4140]
[4141]
[4142]
[4143]
[4144]
[4145]
[4146]
[4147]
[4148]
[4149]
[4150]
[4151]
[4152]
[4153]
[4154]
[4155]
[4156]
[4157]
[4158]
[4159]
[4160]
[4161]
[4162]
[4163]
[4164]
[4165]
[4166]
[4167]
[4168]
[4169]
[4170]
[4171]
[4172]
[4173]
[4174]
[4175]
[4176]
[4177]
[4178]
[4179]
[4180]
[4181]
[4182]
[4183]
[4184]
[4185]
[4186]
[4187]
[4188]
[4189]
[4190]
[4191]
[4192]
[4193]
[4194]
[4195]
[4196]
[4197]
[4198]
[4199]
[4200]
[4201]
[4202]
[4203]
[4204]
[4205]
[4206]
[4207]
/*****************************************************************************/
/*
                                  HTTPd.c

WASD VMS Hypertext Transfer Protocol daemon.


COPYRIGHT NOTICE
----------------
WASD VMS Web Services, Copyright (C) 1996-2021 Mark G.Daniel.
(prior to 01-JUL-1997, "HFRD VMS Hypertext Services")

See COPYRIGHT.H for detail.


PRIVILEGES REQUIRED
-------------------
These should be INSTALLed against the image.

ALTPRI   Allows the server account to raise it's prioity above 4 if enabled by
         the /PRIORITY= qualifier.

CMKRNL   Required for single use of $GRANTID system service in DCL.C module.
         This rights identifier is used to mark detached WASD script processes.

DETACH   (IMPERSONATE) Allows the server to impersonate specific accounts
         for scripting and startup purposes.

OPER     used for $BRKTHRU messaging

PRMGBL   Create the permanent global section used by the HTTPDMON utility.

PRMMBX   Used by the DCL scripting module to create permanent mailboxes

PSWAPM   Allows the server process to prevent itself from being swapped out if 
         enabled by the /[NO]SWAP qualifier.

SHMEM    Allow shared section memory between multiple processors
         (VAX only ,for access to the global section used by HTTPDMON).

SYSGBL   Create the system global section used by the HTTPDMON utility.

SYSLCK   Allows SYSTEM locks to be enqueued for sending commands to all
         server processes on a node/cluster (via /DO=/ALL or Admin Menu).

SYSPRV   Used for various purposes, including creating sockets within the
         privileged port range (1-1023, which includes port 80 of course),
         accessing configuration files (which can be protected from world
         access), enable AUTHORIZED write access to the file system, checking
         authentication details, amongst others.

SYSNAM   Is actually not required with version 8.n and later.

WORLD    Allows some functions to obtain information about and affect 
         processes (e.g. scripts) that do not belong to the server process.


QUALIFIERS  (implemented in the CLI.c module)
----------
/ACCEPT=<string>        comma separated list of accepted hosts/domains
/ALL[=<integer>]        /do= this to all server processes on node/cluster
/AUTHORIZE=[SSL|ALL]    authorization may only be used with "https:",
                        all paths must be authorized
/CGI_PREFIX=<string>    prefix to CGI-script variable (symbol) names
/CLUSTER[=<integer>]    /do= this to all server processes on node/cluster
/DBUG                   turn on all "if (Debug)" statements (if compiled DBUG)
/DEMO                   demonstration mode 
/DETACH=>string>        DCL procedure to be run as /USER=
/DO=<string>            command to be passed to server
/ENV=<integer>          do to all servers in this WASD environment
/FILBUF=<integer>       number of bytes in record buffer
/FORMAT=<string>        log record format
/GBLSEC=DELETE          delete the permanent global section (with /INSTANCE=)
/IDENT=<string>         VMS rights identifier name used for detached processes
/INSTANCES=<integer>|CPU|PASSIVE|CONFIG  maximum number of per-node servers
/NOINSTANCES            suppresses the server's desire to $CREPRC new instances
/[NO]LOG[=]             logging enabled/disabled, optional log file name
/[NO]MONITOR            monitor enabled/disabled
/[NO]NETWORK            explicitly enables/disables global network mode
/NETBUF=<integer>       number of bytes in network read buffer
/NOTE=<string>          annotate server process log with this string
/[NO]ODS5               explicit extended file specification (testing only)
/OUTPUT=<file-name>     <stdout> to file
/OUTBUF=<integer>       number of bytes in output buffer
/PERIOD=<integer>       log file period
/PERSONA[=ident]        enable PERSONA services for DCL scripting,
                        optional identifier name controlling persona access
/PERSONA[=AUTHORIZED]   enable persona only if request subject to authorization
/PERSONA[=RELAXED]      optional keyword to allow privileged accounts to script
/PERSONA[=RELAXED=AUTHORIZED] optional keyword to allow privileged accounts
                              to script if request subject to authorization
/PORT=<integer>         server IP port number (overriden by [service] config)
/PRIORITY=<integer>     process priority (0-15)
/[NO]PROFILE            allow/disallow SYSUAF-authenticated access control
/PROFILE=NORULE         SYSUAF profile withput auth rule (pre-8.1 behaviour)
/[NO]PROMISCUOUS[=pwd]  authenticates any user name for path authorization
                        (optional password required for authorization) 
/REJECT=<string>        comma separated list of rejected hosts/domains
/SCRIPT=AS=<string>     detached scripting using this persona
                        (keyword SUBPROCESS forces subprocess scripting)
/SERVICES=<string>      list of [host-name:]port providing HTTP service
/SOFTWAREID=<string>    overrides the server's software ID string
/SYSPRV                 normally operate with SYSPRV enabled (CAUTION!)
/[NO]SSL=               enables Secure Sockets Layer, sets protocol parameters
/[NO]SYSUAF[=ID,PROXY,RELAXED,SSL]
                        allow/disallow SYSUAF authentication, or
                        SYSUAF authentication is allowed by identifier,
                        proxy SYSUAF authentication is allowed,
                        SYSUAF authentication allowed with any current account,
                        SYSUAF authentication is only allowed with "https:"
/[NO]SWAP               allow/disallow process to be swapped out
/USER=<string>          set the username (account) the server executes under
/VALBLK[=16|64]         overrides value block size determination
/VERSION                simply display the server version
/[NO]ZERO               accounting zeroed on startup (default is non-zeroed)


VERSION HISTORY
---------------
See VERSION.H
*/
/*****************************************************************************/

#ifdef WASD_VMS_V7
#undef _VMS__V6__SOURCE
#define _VMS__V6__SOURCE
#undef __VMS_VER
#define __VMS_VER 70000000
#undef __CRTL_VER
#define __CRTL_VER 70000000
#endif

/* standard C header files */
#include <builtins.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

/* VMS related header files */
#include <afrdef.h>
#include <descrip.h>
#include <devdef.h>
#include <iodef.h>
#include <jpidef.h>
#include <libdef.h>
#include <libdtdef.h>
#include <libclidef.h>
#include <libicb.h>
#include <lnmdef.h>
#include <opcdef.h>
#include <prvdef.h>
#include <prcdef.h>
#include <psldef.h>
#include <secdef.h>
#include <ssdef.h>
#include <stsdef.h>
#include <syidef.h>
#include <uaidef.h>

/* application-related header files */
#include "wasd.h"
#include "sha1.h"
#include "base64.h"
#include "copyright.h"

#ifdef __ia64
#  define ELVEN
#endif
#ifdef __x86_64
#  define ELVEN
#endif

#ifdef ELVEN
/*** hmmm, elfdef.h preceding wasd.h results in:

    } LKIDEF;
......^
%CC-E-NOLINKAGE, In this declaration, "LKIDEF" has no linkage and has a prior
declaration in this scope at line number *** in file
WASD_ROOT:[SRC.HTTPD]WASD.H;1.
at line number 81 in module LKIDEF of text library
SYS$COMMON:[SYSLIB]SYS$STARLET_C.TLB;1

(HP C V7.1-011 on OpenVMS IA64 V8.3-1H1)
(VSI C V7.4-001 on OpenVMS IA64 V8.4-2L1)
***/
#include <elfdef.h>
#endif

/* a control-y turned into a warning */
#define SS_W_CONTROLY (SS$_CONTROLY & 0xfffffffe)

#define WASD_MODULE "HTTPD"

/******************/
/* global storage */
/******************/

/*
   These are the required privileges of the executing HTTP server.
   The server ACCOUNT should only have TMPMBX and NETMBX (just for
   extra security, policy ... keep privileged accounts to a minimum).
   Script processes are created only with the process's current privileges,
   which are always maintained at TMPMBX and NETMBX.  If additional
   privileges are required for any particular purpose (e.g. binding to
   a privileged IP port) then they are enabled, the action performed,
   and then they are disabled again immediately.
*/
ulong  AltPriMask [2] = { PRV$M_ALTPRI, 0 },
       AveJoePrvMask [2] = { PRV$M_NETMBX | PRV$M_TMPMBX, 0 },
       CrePrcMask [2] = { PRV$M_DETACH | PRV$M_SYSPRV, 0 },
       DetachMask [2] = { PRV$M_DETACH, 0 },
       GblSecPrvMask [2] = { PRV$M_SYSPRV | PRV$M_SYSGBL |
                                 PRV$M_PRMGBL, 0 },
//       GrantIdMask [2] = { PRV$M_CMKRNL | PRV$M_WORLD, 0 },
       GrantIdMask [2] = { PRV$M_CMKRNL | PRV$M_WORLD | PRV$M_DIAGNOSE, 0 },
//       MailboxMask [2] = { PRV$M_WORLD | PRV$M_SYSPRV, 0 },
       MailboxMask [2] = { PRV$M_WORLD | PRV$M_SYSPRV | PRV$M_OPER, 0 },
       PrivAcctMask [2] = { PRV$M_SETPRV | PRV$M_SYSPRV, 0 },
       PswapmMask [2] = { PRV$M_PSWAPM, 0 },
       ResetPrvMask [2] = { 0xffffffff, 0xffffffff },
       SecurityMask [2] = { 0, 0x40 /* PRV$M_SECURITY */ },
       SysLckMask [2] = { PRV$M_SYSLCK, 0 },
       SysNamMask [2] = { PRV$M_SYSNAM, 0 },
       SysPrvMask [2] = { PRV$M_SYSPRV, 0 },
#if 1
       WorldMask [2] = { PRV$M_WORLD, 0 };
#else
       WorldMask [2] = { PRV$M_WORLD | PRV$M_SHARE, 0 };
#endif

/*
   Decided to be able to eliminate the debug statements from production
   executables completely.  This will eliminate some largely unused code
   from the images reducing the overall file size, but more importantly
   will eliminate the test and branch execution overhead each time a debug
   statement is encountered.  Do this by conditionally turning the integer
   Debug storage into a constant false value ... compiler optimization of
   an impossible-to-execute section of code does the rest!  Very little
   other code needs to be explicitly conditionally compiled.
*/
#ifdef DBUG
BOOL  Debug;
#else
#define Debug 0
#endif

BOOL  HttpdAlignFaultReport,
      HttpdNetworkMode,
      HttpdServerExecuting,
      HttpdServerStartup,
      HttpdTicking,
      MonitorEnabled,
      NaturalLanguageEnglish,
      NoSwapOut = true,
      OperateWithSysPrv;

int  EfnWait,
     EfnNoWait,
     ExitStatus,
     GblSectionCount,
     GblSectionPermCount,
     GblPageCount,
     GblPagePermCount,
     HttpdAlignFaultCount,
     HttpdDayOfWeek,
     HttpdTickSecond,
     ProcessPriority = 4,
     ServerPort = 80;

int64  HttpdTime64,
       HttpdStartTime64;

ushort  HttpdTime7 [7];

char  HttpdScriptAsUserName [64],
      HttpdServerNote [256],
      NaturalLanguage [64],
      ProcessIdentName [32],
      ServerPortString [8];

/* zero index is used to indicate request is not in a list */
#define SUPERVISOR_LIST_MAX 10
SUPERVISOR_LIST  SupervisorListArray [SUPERVISOR_LIST_MAX+1] =
/* these numbers are staggered so they are not all scanned at any one time */
   { { {0,0,0}, 0, },
     { {0,0,0}, 1, },
     { {0,0,0}, 15, },
     { {0,0,0}, 50, },
     { {0,0,0}, 110, },
     { {0,0,0}, 290, },
     { {0,0,0}, 590, },
     { {0,0,0}, 1100, },
     { {0,0,0}, 3500, },
     { {0,0,0}, 7100, },
     { {0,0,0}, 999999999, } };

/*
Seconds at which the network transfer statistics are updated.
Up until v10.4.0 this was set at 17.
WASDMON requires per-second updates of network data.
Reducing it to 1 should not have a significant impact forr most environments.
It it does, well just bump it back up and recompile!
*/
#define SUPERVISOR_NETWORK_UPDATE 1

struct AnExitHandler  ExitHandler;

ACCOUNTING_STRUCT  *AccountingPtr;
BOOL  AccountingZeroOnStartup;

SYS_INFO  SysInfo;
HTTPD_PROCESS  HttpdProcess;

/* default storage in case the real global section cannot be/is not in use */
HTTPD_GBLSEC  HttpdGblSecDefault;
HTTPD_GBLSEC  *HttpdGblSecPtr;
int  HttpdGblSecPages;

/********************/
/* external storage */
/********************/

extern BOOL  AuthorizationEnabled,
             AuthPromiscuous,
             CliDetach,
             CliDemo,
             CliGblSecDelete,
             CliGblSecNoPerm,
             CliInstanceConfig,
             CliLoggingDisabled,
             CliLoggingEnabled,
             CliMonitorDisabled,
             CliMonitorEnabled,
             CliNetworkMode,
             CliNoNetworkMode,
             CliInstanceNoCrePrc,
             CliOdsExtendedEnabled,
             CliOdsExtendedDisabled,
             CliSysPlus,
             CliTests,
             CliVersion,
             ControlDoAllHttpd,
             DclScriptDetachProcess,
             LoggingEnabled,
             OdsExtended,
             ProtocolHttpsAvailable,
             ProxyServingEnabled;

extern const int64  Delta60Sec,
                    Delta01Sec;

extern int  ActivityTotalMinutes,
            CliServerPort,
            CliLockValueBlockSize,
            HttpdGblSecVersion,
            NetConcurrentMax,
            InstanceEnvNumber,
            InstanceNumber,
            OpcomMessages,
            OpcomTarget,
            RequestHistoryMax;

extern int  ToLowerCase[],
            ToUpperCase[];

extern char  BuildDateTime[],
             BuildInfo[],
             CliLogFileName[],
             CliParameter[],
             CliProcessIdentName[],
             CliScriptAs[],
             CliServices[],
             CliUserName[],
             CommandLine[],
             ControlBuffer[],
             ErrorSanityCheck[],
             HttpdIpPackage[],
             HttpdSesola[],
             HttpdVersion[],
             LoggingFileName[],
             Services[],
             ServerHostPort[],
             SoftwareID[],
             TcpIpAgentInfo[],
             TimeGmtString[],
             WatchFuncCc[];

extern char  *CliOutputPtr;

extern CONFIG_STRUCT  Config;
extern LIST_HEAD  Http2List;
extern LIST_HEAD  RequestList;
extern INSTANCE_STATUS  *InstanceStatusTablePtr;
extern META_CONFIG  *MetaGlobalConfigPtr;
extern META_CONFIG  *MetaGlobalServicePtr;
extern META_CONFIG  *MetaGlobalMsgPtr;
extern PROXY_ACCOUNTING_STRUCT  *ProxyAccountingPtr;
extern WATCH_STRUCT  Watch;

/*****************************************************************************/
/*
*/

void main ()

{
   void  *close_enough_to_the_top = 0xDEFEC8ED;

   int  idx, status,
        GblSecDeleteCount;
   char  *cptr, *sptr, *zptr;
   $DESCRIPTOR (NaturalLanguageDsc, NaturalLanguage);
   ODS_STRUCT  WasdRootOds;

   /*********/
   /* begin */
   /*********/

   /* initialize virtual memory management */
   VmInit ();

   /* generate version information */
   VersionInfo ();

   /* no global section (yet) gotta have the storage somewhere! */
   HttpdGblSecPtr = &HttpdGblSecDefault;
   HttpdGblSecPages = sizeof(HTTPD_GBLSEC) / 512;
   if (HttpdGblSecPages & 0x1ff) HttpdGblSecPages++;
   AccountingPtr = &HttpdGblSecPtr->Accounting;
   ProxyAccountingPtr = &HttpdGblSecPtr->ProxyAccounting;

   if (VMSnok (status = ParseCommandLine ()))
      exit (status);

#ifdef DBUG
   if (!Debug)
      if ((char*)getenv ("WASD_HTTPD_DBUG"))
         Debug = true;
#endif

   if (CliOutputPtr)
      if (!(stdout = freopen (CliOutputPtr, "w", stdout)))
         exit (vaxc$errno);

   if (Watch.CliEnabled) WatchCliSettings (false);

   if (!CliDemo && !InstanceEnvNumber)
   {
      /* if WASD_ENV defined then use this value in the absence of CLI value */
      if (cptr = SysTrnLnm (WASD_ENV))
         InstanceEnvNumber = atoi (cptr);
      else
         InstanceEnvNumber = INSTANCE_ENV_NUMBER_DEFAULT;
   }

   /* get required server system information */
   HttpdSystemInfo ();

   /* get required server process information */
   HttpdProcessInfo ();

   if (!HttpdProcess.PrivilegedAccount)
   {
      /*********************************************************/
      /* things we're not allowed to do without account SYSPRV */
      /*********************************************************/

      if (AuthPromiscuous)      exit (SS$_NOSYSPRV);
      if (CliDemo)              exit (SS$_NOSYSPRV);
      if (CliDetach)            exit (SS$_NOSYSPRV);
      if (CliGblSecDelete)      exit (SS$_NOSYSPRV);
      if (CliInstanceConfig)    exit (SS$_NOSYSPRV);
      if (CliParameter[0])      exit (SS$_NOSYSPRV);
      if (CliServices[0])       exit (SS$_NOSYSPRV);
      if (CliUserName[0])       exit (SS$_NOSYSPRV);
      if (ControlBuffer[0])     exit (SS$_NOSYSPRV);
      if (HttpdServerNote[0])   exit (SS$_NOSYSPRV);
   }

   if (CliTests)
   {
      /*********/
      /* /TEST */
      /*********/

#if WATCH_MOD
{
      if (strsame (CliParameter, "BASE64", 6))
      {
         base64_self_test (1);
         exit (SS$_NORMAL);
      }
      if (strsame (CliParameter, "DICTIONARY", 4))
      {
         DictTest (CliParameter+4);
         exit (SS$_NORMAL);
      }
#if ODS_DIRECT
      if (strsame (CliParameter, "ODS=DIRECT=", 11) ||
          strsame (CliParameter, "ODS=SEARCH=", 11))
      {
         OdsDirectPerf (CliParameter+4);
         exit (SS$_NORMAL);
      }
#endif /* ODS_DIRECT */
      if (strsame (CliParameter, "MATCH", 5))
      {
         MatchPerf ();
         exit (SS$_NORMAL);
      }
      if (strsame (CliParameter, "MKCERT", 6))
      {
         cptr = SesolaMkCert ();
         FaoToStdout ("!AZ", cptr);
         exit (SS$_NORMAL);
      }
      if (strsame (CliParameter, "QUOTAS", 6))
      {
         uint64  cnt, b64, d64, e64;
         sys$gettim (&b64);
         for (cnt = 100000; cnt; cnt--) WatchServerQuotas(10);
         sys$gettim (&e64);
         d64 = e64 - b64;
         printf ("%llumS %lld/S\n", d64 / 10000,
                                    100000 / (d64 / 10000) * 1000);
         exit (SS$_NORMAL);
      }
      if (strsame (CliParameter, "SHA1", 4))
      {
         SHA1selfTest ();
         exit (SS$_NORMAL);
      }
      if (strsame (CliParameter, "TCPIP=", 6))
      {
         IPADDRESS  IpAddress;
         status = TcpIpStringToAddress (CliParameter+6, &IpAddress);
         exit (status);
      }
      if (strsame (CliParameter, "UTC", 3))
      {
         TimeTest ();
         exit (SS$_NORMAL);
      }
      if (strsame (CliParameter, "WEBDAV=DLM=", 11))
      {
         status = DavWebDlmTest (CliParameter+11);
         exit (status);
      }
      exit (SS$_ABORT); 
}
#else
      FaoToStdout ("%HTTPD-W-TESTS, NOT a compiled option\n");
#endif /* WATCH_MOD */
      exit (SS$_NORMAL); 
   }

   if (CliSysPlus)
   {
      /**********************/
      /* CLI system+ report */
      /**********************/

      sysPlusReport (NULL);
      exit (SS$_NORMAL);
   }

   if (CliDetach)
   {
      /****************************/
      /* create a detached server */
      /****************************/

      exit (HttpdDetachServerProcess ());
   }

   if (CliInstanceConfig)
   {
      /*****************************/ 
      /* ensure config values used */
      /*****************************/ 

      HttpdGblSecInit ();
      exit (InstanceUseConfig()); 
   }

   if (CliGblSecDelete)
   {
      /**************************/
      /* delete global sections */
      /**************************/

      /* permanent ones, that is */
      GblSecDeleteCount = 0;
      status = HttpdGblSecInit ();
      if (VMSok (status)) GblSecDeleteCount++;
      status = GraphActivityGblSecInit ();
      if (VMSok (status)) GblSecDeleteCount++;
      FaoToStdout ("%HTTPD-!AZ-GBLSEC, deleted !UL global sections\n",
                   GblSecDeleteCount ? "I" : "W", GblSecDeleteCount);
      exit (SS$_NORMAL); 
   }

   /* initialize the resources and locks for multi-instance processing */
   InstanceLockInit ();

   if (HttpdServerNote[0])
   {
      /***************************/
      /* annotate the server log */
      /***************************/

      status = ControlCommand (HttpdServerNote, !ControlBuffer[0]);
      /* can be used standalone or in conjunction with /DO=.. */
      if (!ControlBuffer[0] || VMSnok (status)) exit (status);
   }

   if (ControlBuffer[0])
   {
      /*****************************/
      /* control the HTTPd process */
      /*****************************/

      exit (ControlCommand (ControlBuffer, true));
   }

   /***************************/
   /* software and image info */
   /***************************/

   /* output the GNU GENERAL PUBLIC LICENSE message */
   FaoToStdout ("%HTTPD-I-SOFTWAREID, !AZ\n!AZ",
                SoftwareID, CopyRightMessageBrief);

   HttpdImageInfo ();
   FaoToStdout ("%HTTPD-I-IMAGE, !AZ\n", HttpdProcess.ImageInfo);

   if (CliVersion)
   {
      FaoToStdout ("-HTTPD-I-BUILD, !AZ, CC (!#AZ/!UL) !AZ\n",
                   BuildDateTime,
                   strchr(__VMS_VERSION, ' ') - __VMS_VERSION,
                   __VMS_VERSION, __DECC_VER,
                   WatchFuncCc);
      TcpIpSetAgentInfo ();
      FaoToStdout ("-HTTPD-I-SYSTEM, !AZ !UL CPU!%s !ULMB VMS !AZ\n",
                   SysInfo.HwName, SysInfo.AvailCpuCnt,
                   SysInfo.MemoryMB, SysInfo.Version);
      FaoToStdout ("-HTTPD-I-TCPIP, !AZ\n", TcpIpAgentInfo);
      FaoToStdout ("-HTTPD-I-TLS, !AZ!AZ\n",
                   cptr = SesolaVersion(true), *cptr ? "" : "none");

      status = SetGlobalSymbol ("HTTPD_VERSION", HTTPD_VERSION);
      if (VMSnok(status)) exit (status);
      exit (SS$_NORMAL); 
   }

   if (CliDemo)
   {
      /*************/
      /* demo mode */
      /*************/

      /* with 'instances' demonstration mode was becoming a little complex */
      CliLoggingEnabled = false;
      AuthPromiscuous = CliInstanceNoCrePrc =
         CliLoggingDisabled = CliGblSecNoPerm = true;
      InstanceEnvNumber = DEMO_INSTANCE_GROUP_NUMBER;
      if (!CliServices[0])
      {
         strcpy (CliServices, "http://*:7080");
         if (ProtocolHttpsAvailable) strcat (CliServices, ",https://*:7443");
      }
   }

   /****************/
   /* HTTPd server */
   /****************/

#if WATCH_OPENSSL_30
   int64  dura64;
   WatchDuration (&dura64, 0, 0);
#endif

   /* failsafe for runaway startups (yup, happened with multi-instances) */
   if (SysTrnLnm (WASD_STARTUP_ABORT)) sys$delprc (0, 0);

   HttpdServerExecuting = HttpdServerStartup = true;

   /* initialize ticker */
   HttpdTick (0);

   FaoToStdout ("%HTTPD-I-STARTUP, !20%D\n", &HttpdStartTime64);

   /* start collection alignment faults as early as possible */
   HttpdAlignFault ("START");

   cptr = v10orPrev10(CONFIG_WASD_ROOT,-1);
   OdsStructInit (&WasdRootOds, true);
   OdsParse (&WasdRootOds, cptr, strlen(cptr), NULL, 0,
             NAM$M_NOCONCEAL | NAM$M_SYNCHK, 0, 0);
   sptr = strstr (WasdRootOds.ExpFileName, ".][000000]");
   if (sptr) SET2(sptr,']\0');

   FaoToStdout ("%HTTPD-I-!#AZ, !AZ\n",
                strchr(cptr,':') - cptr, cptr, WasdRootOds.ExpFileName);

   FaoToStdout ("%HTTPD-I-ENVIRONMENT, !UL\n", InstanceEnvNumber);

   FaoToStdout ("%HTTPD-I-SYSTEM, !AZ VMS !AZ\n",
                SysInfo.HwName, SysInfo.Version);

   if (HttpdProcess.Grp <= SysInfo.MaxSysGroup)
      FaoToStdout (
"%HTTPD-W-SYSPRV, operating with implicit SYSPRV (UIC group !UL)\n",
                   HttpdProcess.Grp);

   /* get the TCP/IP agent information */
   TcpIpSetAgentInfo ();
   FaoToStdout ("%HTTPD-I-TCPIP, !AZ\n", TcpIpAgentInfo);

   switch (HttpdProcess.Mode)
   {
      case JPI$K_INTERACTIVE : HttpdProcess.ModeName = "INTERACTIVE"; break;
      case JPI$K_NETWORK     : HttpdProcess.ModeName = "NETWORK"; break;
      case JPI$K_OTHER       : HttpdProcess.ModeName = "OTHER"; break;
      case JPI$K_BATCH       : HttpdProcess.ModeName = "BATCH"; break;
      default : HttpdProcess.ModeName = "?";
   }
   FaoToStdout ("%HTTPD-I-MODE, !AZ\n", HttpdProcess.ModeName);
   if (HttpdProcess.Mode == JPI$K_NETWORK) HttpdNetworkMode = true;
   /* the server process' detached scripts can still have mode overridden */
   if (CliNetworkMode) HttpdNetworkMode = true;
   if (CliNoNetworkMode) HttpdNetworkMode = false;

   /* set the flag and report indicating whether ODS-5 is supported */
   OdsSetExtended ();
   /* (testing only) */
   if (CliOdsExtendedEnabled) OdsExtended = true;
   if (CliOdsExtendedDisabled) OdsExtended = false;

   /* ensure the GMT time/logical is available */
   TimeSetHttpdUTC ();
   FaoToStdout ("%HTTPD-I-GMT, !AZ\n", TimeGmtString);

   /* set up and declare the exit handler */
   ExitHandler.HandlerAddress = &HttpdExit;
   ExitHandler.ArgCount = 1;
   ExitHandler.ExitStatusPtr = &ExitStatus;
   if (VMSnok (status = sys$dclexh (&ExitHandler)))
      ErrorExitVmsStatus (status, "sys$dclexh()", FI_LI);
   HttpdOnControlY (false);

   /* join per-node and per-cluster instances (the earlier the better) */
   InstanceServerInit ();

   /* make sure the process' privileges are those of a mere mortal */
   if (VMSnok (status = sys$setprv (0, &ResetPrvMask, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);
   if (VMSnok (status = sys$setprv (1, &AveJoePrvMask, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);

   if (OperateWithSysPrv && OPERATE_WITH_SYSPRV)
   {
      /* looks like we're been asked to use Superman's Xray vision! */
      if (VMSnok (status = sys$setprv (1, &SysPrvMask, 0, 0)))
         ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);

      /* OK, now reset the SYSPRV bit so it isn't manipulated */
      CrePrcMask[0] &= ~PRV$M_SYSPRV;
      GblSecPrvMask[0] &= ~PRV$M_SYSPRV;
      MailboxMask[0] &= ~PRV$M_SYSPRV;
      SysPrvMask[0] &= ~PRV$M_SYSPRV;

      FaoToStdout ("%HTTPD-I-SYSPRV, operating with SYSPRV\n");
   }
   else
   if (OperateWithSysPrv)
   {
      OperateWithSysPrv = false;
      FaoToStdout ("%HTTPD-W-SYSPRV, is NOT a compiled option\n");
   }

   if (ProcessPriority > 15) ProcessPriority = 15;
   if (VMSnok (status = sys$setprv (1, &AltPriMask, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);
   if (VMSnok (status = sys$setpri (0, 0, ProcessPriority, 0, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setpri()", FI_LI);
   if (VMSnok (status = sys$setprv (0, &AltPriMask, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);

   /* anywhere near before starting logging! */
   NetGetServerHostName ();

   /* read the server configuration file */
   ConfigLoad (&MetaGlobalConfigPtr);

   /* a blast from the past */
   if (CliServerPort)
      ServerPort = CliServerPort;
   else
   if (Config.cfServer.DefaultPort)
      ServerPort = Config.cfServer.DefaultPort;
   if (ServerPort < 1 || ServerPort > 65535)
      ErrorExitVmsStatus (0, "IP port", FI_LI);
   sprintf (ServerPortString, "%d", ServerPort);

   /* initialize the GZIP module and ZLIB sharable image */
   GzipInit ();

   /* set/reset global section used by CLI control and the HTTPMON utility */
   if (!CliDemo) HttpdGblSecInit ();

   /* make any adjustments required after configuration load */
   InstanceFinalInit ();

   /* initialize Secure Sockets Layer, if available and if required */
   SesolaInit ();

   /* initialise (or not) HTTP/2 processing */
   Http2Init ();

   /* get the configured services */
   ServiceConfigLoad (&MetaGlobalServicePtr);

   /* set this instance's process name */
   InstanceProcessName ();

   {
      /* don't use WASD functions to write into the locked areas */
      $DESCRIPTOR (FaoDsc, "%HTTPD-I-STARTUP, !20%D, !AZ\0");
      $DESCRIPTOR (StringDsc, ""); 

      StringDsc.dsc$w_length = sizeof(HttpdGblSecPtr->StatusMessage)-1;
      StringDsc.dsc$a_pointer = HttpdGblSecPtr->StatusMessage;
      InstanceMutexLock (INSTANCE_MUTEX_HTTPD);
      sys$fao (&FaoDsc, NULL, &StringDsc, 0, HttpdProcess.PrcNam);
      InstanceMutexUnLock (INSTANCE_MUTEX_HTTPD);
   }

   /* note the process name has to be set before OPCOM can be used */
   if (OpcomMessages)
      FaoToOpcom ("%HTTPD-I-STARTUP, !AZ", SoftwareID);

   /* update (reset) the request information */
   if (MonitorEnabled) RequestGblSecUpdate (NULL);

   /* now that we have the accounting data (in the global section) */
   if (AccountingZeroOnStartup) ControlZeroAccounting ();

   /* set up a rights identifier name (currently for detached scripting) */
   zptr = (sptr = ProcessIdentName) + sizeof(ProcessIdentName)-1;
   if (CliProcessIdentName[0])
      for (cptr = CliProcessIdentName; *cptr && sptr < zptr; *sptr++ = *cptr++);
   else
   {
      /* server-set rights identifiers begin with the following */
      for (cptr = PROCESS_RIGHTS_ID_PREFIX; *cptr; *sptr++ = *cptr++);
      for (cptr = HttpdProcess.PrcNam; *cptr && sptr < zptr; cptr++)
         if (isalnum(*cptr)) *sptr++ = TOUP(*cptr); else *sptr++ = '_';
   }
   *sptr = '\0';
   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "!&Z", ProcessIdentName);

   if (CliMonitorDisabled)
      MonitorEnabled = false;
   else
   if (Config.cfMisc.MonitorEnabled || CliMonitorEnabled)
      MonitorEnabled = true;
   else
      MonitorEnabled = false;

   /* initialize message database, check contents of some of those messages */
   MsgConfigLoad (&MetaGlobalMsgPtr);
   ErrorCheckReportFormats ();

   /* WebDAV initialisation */
   DavWebInit ();

   /* authentication/authorization configuration */
   AuthConfigInit ();

   /*
      Now that authentication (potentially using X509) has been configured
      the multi-instance SSL session cache (if required) can be initialized
      and appropriately adjust the record size upwards to accomodate sessions
      potentially including client certificate details.
   */
   SesolaCacheInit ();

   /* load the rule mapping database */
   MapUrl_Load ();

   /* initialize proxy processing */
   ProxyInit ();

   /* if required initialize the TCP/IP host name/address cache */
   if (Config.cfMisc.DnsLookupClient || ProxyServingEnabled)
      TcpIpHostCacheInit ();

   /* check for and if necessary enable the default scripting account */
   HttpdScriptAs ();

   /* initialize request virtual memory management */
   VmRequestInit (); 

   /* initialize DCL processing */
   DclInit ();

   /* initialize file cache  */
   CacheInit (true);

   /* initialize activity statistics, record server event */
   GraphActivityGblSecInit ();
   GraphActivityEvent (ACTIVITY_STARTUP);

   /* initialize the language environment */
   if (VMSok (status = lib$get_users_language (&NaturalLanguageDsc)))
   {
      for (cptr = NaturalLanguage; *cptr && !ISLWS(*cptr); cptr++);
      *cptr = '\0';
      if (strsame (NaturalLanguage, "ENGLISH", -1))
         NaturalLanguageEnglish = true;
      else
      {
         NaturalLanguageEnglish = false;
         FaoToStdout ("%HTTPD-I-LANGUAGE, natural language is !AZ\n",
                      NaturalLanguage);
      }
   }
   else
   {
      if (status == LIB$_ENGLUSED)
      {
         NaturalLanguageEnglish = true;
         strcpy (NaturalLanguage, "ENGLISH");
         FaoToStdout (
            "%HTTPD-I-LANGUAGE, natural language has defaulted to !AZ\n",
            NaturalLanguage);
      }
      else
         ErrorExitVmsStatus (status, "lib$get_users_language()", FI_LI);
   }

   /* initialize request history mechanism (ensure it's reasonable!) */
   RequestHistoryMax = Config.cfMisc.RequestHistory;
   if (RequestHistoryMax > 999) RequestHistoryMax = 0;

   /* disable process swapping */
   if (NoSwapOut)
   {
      if (VMSnok (status = sys$setprv (1, &PswapmMask, 0, 0)))
         ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);
      if (VMSnok (status = sys$setswm (1)))
         ErrorExitVmsStatus (status, "sys$setswm()", FI_LI);
      if (VMSnok (status = sys$setprv (0, &PswapmMask, 0, 0)))
         ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);
   }

   /* need SYSPRV to bind to a well-known port */
   sys$setprv (1, &SysPrvMask, 0, 0);

   /* create network services */
   NetCreateService ();

   sys$setprv (0, &SysPrvMask, 0, 0);

   /* get the available BYTLM quota after all server sockets created */
   HttpdProcess.BytLmAvailable = GetJpiBytLm();

   /* initialize logging after service creation (in case of per-service logs) */
   if (VMSnok (status = Logging (NULL, LOGGING_BEGIN)))
      ErrorNoticed (NULL, status, NULL, FI_LI);

   /* ex-officio server host and port */
   if (cptr = SysTrnLnm (WASD_SERVER_HOST_PORT))
      strcpy (ServerHostPort, cptr);

   InstanceMutexLock (INSTANCE_MUTEX_HTTPD);

   /* cancel any startup messages provided for the monitor */
   HttpdGblSecPtr->StatusMessage[0] = '\0';

   /*
      Perhaps a little bit too clever ...
      ALWAYS initialises the zeroeth (instances not enabled) element.
      If instances are NOT enabled then zeroes all the rest too.
      If instances ARE enabled then zeroes only the element belonging to it.
   */
   for (idx = 0;;)
   {
      AccountingPtr->CurrentInstanceConnected[HTTP12][idx] =
         AccountingPtr->CurrentInstanceConnected[HTTP1][idx] =
         AccountingPtr->CurrentInstanceConnected[HTTP2][idx] =
         AccountingPtr->CurrentInstanceProcessing[HTTP12][idx] =
         AccountingPtr->CurrentInstanceProcessing[HTTP1][idx] =
         AccountingPtr->CurrentInstanceProcessing[HTTP2][idx] = 0;

      AccountingPtr->CurrentDclScriptCgiPlus[idx] =
         AccountingPtr->CurrentDclScriptProcess[idx] =
         AccountingPtr->CurrentDclScriptRTE[idx] =
         AccountingPtr->CurrentDECnetTasks[idx] =
         AccountingPtr->CurrentDECnetCGI[idx] =
         AccountingPtr->CurrentDECnetOSU[idx] =
         AccountingPtr->CurrentPersistentHttp1[idx] =
         AccountingPtr->CurrentThrottleProcessing[idx] =
         AccountingPtr->CurrentThrottleQueued[idx] =
         AccountingPtr->CurrentWebSockets[idx] = 0;

      if (InstanceNumber)
         if (idx == InstanceNumber)
            break;
         else
            idx = InstanceNumber;
      else
      if (idx++ >= INSTANCE_MAX)
         break;
   }

   NetUpdateConnected (NULL, 0);
   NetUpdateProcessing (NULL, 0);

   AccountingPtr->InstanceNodeData[InstanceNumber].StartupCount++;
   AccountingPtr->InstanceNodeData[InstanceNumber].StartTime64 = HttpdStartTime64;

   AccountingPtr->StartupCount++;

   InstanceMutexUnLock (INSTANCE_MUTEX_HTTPD);

   if (CliDemo)
   {
      /*************/
      /* demo mode */
      /*************/

      FaoToStdout (
"%HTTPD-I-DEMO, demonstration mode\n\
1.i subprocess scripting\n\
2.i promiscuous authentication\n\
3.i directory access control files ignored\n\
4.i [DirAccess] enabled\n\
5.i [DirMetaInfo] enabled\n\
6.i [DirWildcard] enabled\n\
7.i [Logging] disabled\n\
8.i [ReportBasicOnly] disabled\n\
9.i [ReportMetaInfo] enabled\n");

      /*
         Subprocess scripting is forced in DCL.C
         Logging is disabled and promiscuous authentication enabled
         in the previous if(CliDemo) section.
      */
      Config.cfReport.BasicOnly = false;
      Config.cfReport.MetaInfoEnabled = true;
      Config.cfDir.Access = true;
      Config.cfDir.AccessSelective = false;
      Config.cfDir.MetaInfoEnabled = true;
      Config.cfDir.WildcardEnabled = true;
   }

   HttpdSysProtProcDmp ();

   HttpdServerStartup = false;

   /*****************************/
   /* begin to process requests */
   /*****************************/

   FaoToStdout ("%HTTPD-I-BEGIN, !20%D, !AZ accepting requests\n",
                0, HttpdProcess.PrcNam);

#if WATCH_OPENSSL_30
   WatchDuration (&dura64, FI_LI);
#endif

   /* ready to accept requests */
   InstanceReady ();

   /* if WATCHing of the startup was suppressed activate from here-on */
   if (Watch.CliEnabled) WatchCliSettings (true);

   /* queue accepts on all services (as an AST so no interruptions) */
   SysDclAst (NetAcceptBegin, 0);

   /*
      Just set and wait!
      Well that's the way it should be anyway.  BUT ...
      Whenever $GRANTID() is used in DclSysCommandAst() this $HIBER()
      (very) occasionally returns!!  Apparently $GRANTID works by queuing
      a kernel mode AST to the target process with setimr, wake, and cantimr
      involved.  This leaves windows for possible spurious wakes.
      Just keep track of these for interest' sake!
   */
   for (;;)
   {
      sys$hiber ();
      /* do not use a mutex here! an AST delivery could break the logic!! */
      AccountingPtr->SpuriousWakeCount++;
   }
   exit (SS$_BUGCHECK);
}

/*****************************************************************************/
/*
Determine whether a function has been called as an AST or directly in a code
path.  Three contexts are involved; 1) this function, 2) call to this function,
3) calling function.  Hence the two previous contexts.  If the third context is
from system space then it's (in the context of this WASD usage) an AST.

For 64 bit platforms use the LIB$ API.

For VAX use a solution cobbled together from fragments out there on the 'net.

For test see "/$/HttpdIsAstCall/" in RequestParseExecute().
*/

BOOL HttpdIsAstCall ()

{
#ifdef __ALPHA

   int  retval;
   struct invo_context_blk  icb;

   /*********/
   /* begin */
   /*********/

   lib$get_curr_invo_context (&icb);
   retval = lib$get_prev_invo_context (&icb);
   if (retval) retval = lib$get_prev_invo_context (&icb);

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdIsAstCall() Alpha !UL !UL !6XL !&B !8XL!8XL",
                 retval,
                 icb.libicb$l_context_length,
                 icb.libicb$v_fflags_bits,
                 icb.libicb$v_ast_frame,
                 (ulong*)icb.libicb$q_program_counter[1],
                 (ulong*)icb.libicb$q_program_counter[0]);

   if (retval)
      return ((ulong*)icb.libicb$q_program_counter[1] != 0);
   else
      return (false);

#endif /* __ALPHA */

#ifdef __ia64

   int  retval;
   struct invo_context_blk  icb;

   /*********/
   /* begin */
   /*********/

   lib$i64_init_invo_context (&icb, LIBICB$K_INVO_CONTEXT_VERSION);
   lib$i64_get_curr_invo_context (&icb);
   retval = lib$i64_get_prev_invo_context (&icb);
   if (retval) retval = lib$i64_get_prev_invo_context (&icb);

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdIsAstCall() ia64 !UL !UL !6XL !8XL!8XL",
                 retval,
                 icb.libicb$l_context_length,
                 icb.libicb$v_fflags_bits,
                 ((ulong*)&icb.libicb$ih_pc)[1],
                 ((ulong*)&icb.libicb$ih_pc)[0]);

   if (retval)
      return (((ulong*)&icb.libicb$ih_pc)[1] != 0);
   else
      return (false);

#endif /* __ia64 */

#ifdef __x86_64

   int  retval;
   struct invo_context_blk  icb;

   /*********/
   /* begin */
   /*********/

   lib$x86_init_invo_context (&icb, LIBICB$K_INVO_CONTEXT_VERSION);
   lib$x86_get_curr_invo_context (&icb);
   retval = lib$x86_get_prev_invo_context (&icb);
   if (retval) retval = lib$x86_get_prev_invo_context (&icb);

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdIsAstCall() ia64 !UL !UL !6XL !8XL!8XL",
                 retval,
                 icb.libicb$l_context_length,
                 icb.libicb$v_fflags_bits,
                 ((ulong*)&icb.libicb$ih_ip)[1],
                 ((ulong*)&icb.libicb$ih_ip)[0]);

   if (retval)
      return (((ulong*)&icb.libicb$ih_ip)[1] != 0);
   else
      return (false);

#endif /* __x86_64 */
}

/*****************************************************************************/
/*
Write the supplied text to the server process <stdout>.
*/

void HttpdNoteThis (char* note)

{
   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdNoteThis() !AZ", note);

   if (!note || !note[0]) return;

   FaoToStdout ("%HTTPD-I-NOTE, !20%D, !AZ\n", 0, note);
}

/*****************************************************************************/
/*
Equivalent of $ DEFINE /EXEC SYS$PROTECTED_PROCDMP SYS$LOGIN:
*/

void HttpdSysProtProcDmp ()

{
   static $DESCRIPTOR (LogNameDsc, "SYS$PROTECTED_PROCDMP");
   static $DESCRIPTOR (LogTableDsc, "LNM$PROCESS");
   static char SysErrLog [] =  "SYS$LOGIN:";
   static uchar  ExecMode = 1;  /* PSL$C_EXEC */
   static struct {
      short int  buf_len;
      short int  item;
      unsigned char   *buf_addr;
      unsigned short  *ret_len;
   } CreLnmItem [2];

   int  status;

   /*********/
   /* begin */
   /*********/

   CreLnmItem[0].item = LNM$_STRING;
   CreLnmItem[0].buf_addr = SysErrLog;
   CreLnmItem[0].buf_len = sizeof(SysErrLog)-1;

   if (VMSnok (status = sys$setprv (1, &SysNamMask, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);

   status = sys$crelnm (0, &LogTableDsc, &LogNameDsc, &ExecMode, &CreLnmItem);
   if (VMSnok(status)) exit (status);

   if (VMSnok (status = sys$setprv (0, &SysNamMask, 0, 0)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);
}

/*****************************************************************************/
/*
Get required system information.
*/

HttpdSystemInfo ()

{
   static $DESCRIPTOR (DECnetDeviceDsc, "_NET:");
   static $DESCRIPTOR (NetStartupStatusDsc, "NET$STARTUP_STATUS");
   static $DESCRIPTOR (LnmSystemTableDsc, "LNM$SYSTEM_TABLE");

   static ushort  Length;
   static char  CsidNodeName [16],
                CsidVersion [9],
                DECnetScratch [32];

   static VMS_ITEM_LIST3
   DECnetLnmItem [] =
   {
      { sizeof(DECnetScratch), LNM$_STRING, NULL, 0 },
      { 0,0,0,0 }
   };

   static VMS_ITEM_LIST3
   SyiItem [] =
   {
     { sizeof(SysInfo.AvailCpuCnt), SYI$_AVAILCPU_CNT,
       &SysInfo.AvailCpuCnt, 0 },
     { sizeof(SysInfo.HwName)-1, SYI$_HW_NAME,
       &SysInfo.HwName, &SysInfo.HwNameLength },
     { sizeof(SysInfo.MaxSysGroup), SYI$_MAXSYSGROUP,
       &SysInfo.MaxSysGroup, 0 },
     { sizeof(SysInfo.MemSize)-1, SYI$_MEMSIZE, &SysInfo.MemSize, 0 },
     { sizeof(SysInfo.PageSize)-1, SYI$_PAGE_SIZE, &SysInfo.PageSize, 0 },
     { sizeof(SysInfo.NodeName)-1, SYI$_NODENAME,
       &SysInfo.NodeName, &SysInfo.NodeNameLength },
     { sizeof(SysInfo.Version)-1, SYI$_VERSION, &SysInfo.Version, 0 },
     { sizeof(SysInfo.BootTime64), SYI$_BOOTTIME, &SysInfo.BootTime64, 0 },
     { sizeof(SysInfo.ClusterMember), SYI$_CLUSTER_MEMBER,
       &SysInfo.ClusterMember, 0 },
     { 0,0,0,0 }
   };

   static VMS_ITEM_LIST3
   SyiCsidItem [] =
   {
     { sizeof(CsidNodeName)-1, SYI$_NODENAME, &CsidNodeName, 0 },
     { sizeof(CsidVersion)-1, SYI$_VERSION, &CsidVersion, 0 },
     { 0,0,0,0 }
   };

   int  status,
        CsidVersionInteger;
   ushort  DECnetChannel;
   ulong  CsidAdr;
   char  *cptr, *sptr;
   IO_SB  IOsb;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdSystemInfo()");

   /* get system information */
   status = sys$getsyiw (EfnWait, 0, 0, &SyiItem, &IOsb, 0, 0);
   if (VMSok (status)) status = IOsb.Status;
   if (VMSnok (status)) ErrorExitVmsStatus (status, NULL, FI_LI);

   if (cptr = getenv("WASD_VMS_VERSION"))
      strncpy (SysInfo.Version, cptr, sizeof(SysInfo.Version));

   SysInfo.HwName[SysInfo.HwNameLength] = '\0';
   for (cptr = sptr = SysInfo.HwName; *cptr; *sptr++ = *cptr++)
      while (SAME2(cptr,'  ')) cptr++;
   *sptr = '\0';
   while (sptr > SysInfo.HwName && *(sptr-1) == ' ') sptr--;
   *sptr = '\0';
   SysInfo.NodeName[SysInfo.NodeNameLength] = '\0';
   SysInfo.Version[sizeof(SysInfo.Version)-1] = '\0';
   for (cptr = SysInfo.Version; *cptr && *cptr != ' '; cptr++);
   *cptr = '\0';
   if (isalpha(SysInfo.Version[0]) &&
       isdigit(SysInfo.Version[1]) &&
       SysInfo.Version[2] == '.' &&
       isdigit(SysInfo.Version[3]))
   {
      /* e.g. "V7.3" */
      SysInfo.VersionInteger = ((SysInfo.Version[1]-48) * 100) +
                               ((SysInfo.Version[3]-48) * 10);
      /* if something like "V7.3-2" */
      if (SysInfo.Version[4] == '-')
         if (isdigit(SysInfo.Version[5]))
            SysInfo.VersionInteger += SysInfo.Version[5]-48;
   }
   else
   {
      FaoToStdout (
"%HTTPD-E-VMS, cannot understand VMS version string \"!AZ\"\n\
-VMS-I-KLUDGE, continue by $ DEFINE /SYSTEM WASD_VMS_VERSION \"Vn.n\"\n",
                   SysInfo.Version);
      exit (SS$_BUGCHECK);
   }

   /* the number of pagelets supported in an architecture page */
   SysInfo.PageFactor = SysInfo.PageSize / 512;
   (uint)SysInfo.MemoryMB = (uint64)SysInfo.MemSize *
                            (uint64)SysInfo.PageFactor / 2048;
   if (SysInfo.MemoryMB > 4095)
      sprintf (SysInfo.MemoryMBGB, "%dGB", SysInfo.MemoryMB / 1024);
   else
      sprintf (SysInfo.MemoryMBGB, "%dMB", SysInfo.MemoryMB);

   if (SysInfo.PageFactor >= 16)
      /* q&d - try and cater for systems with up to 64GB memory */
      SysInfo.MemoryMB = SysInfo.MemSize * (SysInfo.PageFactor / 16) / 128;
   else
      SysInfo.MemoryMB = SysInfo.MemSize * SysInfo.PageFactor / 2048;

   /* versions earlier than 7.0 do not support EFN$C_ENF */
   if (SysInfo.VersionInteger >= 700)
      EfnWait = EfnNoWait = EFN$C_ENF;
   else
   {
      /* and require a unique event flag number */
      if (VMSnok (status = lib$get_ef (&EfnWait)))
         ErrorExitVmsStatus (status, "lib$get_ef()", FI_LI);
      if (VMSnok (status = lib$get_ef (&EfnNoWait)))
         ErrorExitVmsStatus (status, "lib$get_ef()", FI_LI);
   }

   /* establish whether DECnet is running and guess it's version */
   status = sys$assign (&DECnetDeviceDsc, &DECnetChannel, 0, 0);
   if (VMSok (status))
   {
      sys$dassgn (DECnetChannel);
      status = sys$trnlnm (0, &LnmSystemTableDsc, &NetStartupStatusDsc,
                           0, &DECnetLnmItem);
      if (VMSok (status))
         SysInfo.DECnetVersion = 5;
      else
         SysInfo.DECnetVersion = 4;
   }
   else
      SysInfo.DECnetVersion = 0;

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
"!&Z !&Z !&Z ver:!UL MB:!UL cpu:!UL DECnet:!UL EfnWait:!UL EfnNoWait:!UL",
                 SysInfo.NodeName, SysInfo.HwName, SysInfo.Version,
                 SysInfo.VersionInteger, SysInfo.MemoryMB,
                 SysInfo.AvailCpuCnt, SysInfo.DECnetVersion,
                 EfnWait, EfnNoWait);

   /* 16 bytes for VAX and pre-V8.2 Alpha and Itanium, otherwise 64 bytes */ 
   SysInfo.LockValueBlockSize = LOCK_VALUE_BLOCK_16;

   if (SysInfo.VersionInteger >= 820)
      SysInfo.LockValueBlockSize = LOCK_VALUE_BLOCK_64;

   /* search the cluster for anything not 64 bit value block compliant */
   CsidAdr = -1;
   for (;;)
   {
      memset (&CsidNodeName, 0, sizeof(CsidNodeName));
      memset (&CsidVersion, 0, sizeof(CsidVersion));

      /* get cluster system information */
      status = sys$getsyiw (EfnWait, &CsidAdr, 0, &SyiCsidItem, &IOsb, 0, 0);
      if (VMSok (status)) status = IOsb.Status;
      if (status == SS$_NOMORENODE) break;
      if (status == SS$_UNREACHABLE)
      {
         ErrorNoticed (NULL, status, "unexpected cluster response", FI_LI);
         SysInfo.LockValueBlockSize = LOCK_VALUE_BLOCK_16;
         continue;
      }
      if (VMSnok (status)) ErrorExitVmsStatus (status, NULL, FI_LI);

      for (cptr = CsidVersion; *cptr && *cptr != ' '; cptr++);
      *cptr = '\0';
      if (isalpha(CsidVersion[0]) &&
          isdigit(CsidVersion[1]) &&
          CsidVersion[2] == '.' &&
          isdigit(CsidVersion[3]))
      {
         /* e.g. "V7.3" */
         CsidVersionInteger = ((CsidVersion[1]-48) * 100) +
                               ((CsidVersion[3]-48) * 10);
         /* if something like "V7.3-2" */
         if (CsidVersion[4] == '-')
            if (isdigit(CsidVersion[5]))
               CsidVersionInteger += CsidVersion[5]-48;
      }
      else
         ErrorNoticed (NULL, SS$_BUGCHECK, "VMS version string", FI_LI);

      if (CsidVersionInteger < 820)
         SysInfo.LockValueBlockSize = LOCK_VALUE_BLOCK_16;

      if (WATCH_MODULE(WATCH_MOD__OTHER))
         WatchThis (WATCHALL, WATCH_MOD__OTHER, "!&Z !&Z !UL",
                    CsidNodeName, CsidVersion, CsidVersionInteger);
   }

   /* veto! (well sort-of, still SS$_XVALNOTVALID falls-back if necessary) */
   if (CliLockValueBlockSize == -1)
   {
      /* set to the default value for this platform */
      CliLockValueBlockSize == 0;
      if (SysInfo.VersionInteger >= 820)
         SysInfo.LockValueBlockSize = LOCK_VALUE_BLOCK_64;
      else
         SysInfo.LockValueBlockSize = LOCK_VALUE_BLOCK_16;
   }
   else
   if (CliLockValueBlockSize)
   {
      /* set to the command-line specified value */
      SysInfo.LockValueBlockSize = CliLockValueBlockSize;
   }

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "lksb$b_valblk[!UL]", SysInfo.LockValueBlockSize);
}

/*****************************************************************************/
/*
Gets required current process' information/characteristics.  Translates the
server's SYS$OUTPUT process logical name, $DISPLAYs it to get the file name (if
any), checks it's a file, sets the name in storage.
*/

HttpdProcessInfo ()

{
   static ushort  Length;
   static char  LogValue [64];
   static $DESCRIPTOR (LnmJobDsc, "LNM$JOB");
   static $DESCRIPTOR (LnmProcessDsc, "LNM$PROCESS");
   static $DESCRIPTOR (SysOutputDsc, "SYS$OUTPUT");
   static $DESCRIPTOR (SysInputDsc, "SYS$INPUT");
   static $DESCRIPTOR (WASteeSysInputDsc, "WASTEE_SYS$INPUT");
   static $DESCRIPTOR (WASteeSysOutputDsc, "WASTEE_SYS$OUTPUT");

   static VMS_ITEM_LIST3
   JpiItems [] =
   {
     { sizeof(HttpdProcess.Pid), JPI$_PID, &HttpdProcess.Pid, 0 },
     { sizeof(HttpdProcess.Uic), JPI$_UIC, &HttpdProcess.Uic, 0 },
     { sizeof(HttpdProcess.Mode), JPI$_MODE, &HttpdProcess.Mode, 0 },
     { sizeof(HttpdProcess.AuthPriv), JPI$_AUTHPRIV,
       &HttpdProcess.AuthPriv, 0 },
     { sizeof(HttpdProcess.UserName)-1, JPI$_USERNAME,
       &HttpdProcess.UserName, 0 },
     { sizeof(HttpdProcess.PrcNam)-1, JPI$_PRCNAM,
       &HttpdProcess.PrcNam, &HttpdProcess.PrcNamLength },
     { sizeof(HttpdProcess.AstLm), JPI$_ASTLM, &HttpdProcess.AstLm, 0 },
     { sizeof(HttpdProcess.BioLm), JPI$_BIOLM, &HttpdProcess.BioLm, 0 },
     { sizeof(HttpdProcess.BytLm), JPI$_BYTLM, &HttpdProcess.BytLm, 0 },
     { sizeof(HttpdProcess.DioLm), JPI$_DIOLM, &HttpdProcess.DioLm, 0 },
     { sizeof(HttpdProcess.EnqLm), JPI$_ENQLM, &HttpdProcess.EnqLm, 0 },
     { sizeof(HttpdProcess.FilLm), JPI$_FILLM, &HttpdProcess.FilLm, 0 },
     { sizeof(HttpdProcess.Grp), JPI$_GRP, &HttpdProcess.Grp, 0 },
     { sizeof(HttpdProcess.PgFlQuo), JPI$_PGFLQUOTA,
       &HttpdProcess.PgFlQuo, 0 },
     { sizeof(HttpdProcess.PrcLm), JPI$_PRCLM, &HttpdProcess.PrcLm, 0 },
     { sizeof(HttpdProcess.TqLm), JPI$_TQLM, &HttpdProcess.TqLm, 0 },
     { 0,0,0,0 }
   },
   LnmItems [] =
   {
      { sizeof(LogValue)-1, LNM$_STRING, LogValue, &Length },
      { 0,0,0,0 }
   };

   int  status;
   char  *cptr;
   IO_SB  IOsb;
   struct FAB  ScratchFab;
   struct NAM  ScratchNam;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdProcessInfo()");

   /* get some details of the account */
   status = sys$getjpiw (EfnWait, 0, 0, &JpiItems, &IOsb, 0, 0);
   if (VMSok (status)) status = IOsb.Status;
   if (VMSnok (status)) ErrorExitVmsStatus (status, NULL, FI_LI);

   HttpdProcess.UserName[sizeof(HttpdProcess.UserName)-1] = '\0';
   for (cptr = HttpdProcess.UserName; *cptr && *cptr != ' '; cptr++);
   *cptr = '\0';
   HttpdProcess.PrcNam[HttpdProcess.PrcNamLength] = '\0';

   if (HttpdProcess.AuthPriv[0] & PrivAcctMask[0])
      HttpdProcess.PrivilegedAccount = true;
   else
      HttpdProcess.PrivilegedAccount = false;

   status = sys$trnlnm (0, &LnmProcessDsc, &SysInputDsc, 0, &LnmItems);
   if (VMSnok (status)) ErrorExitVmsStatus (status, NULL, FI_LI);
   if (!SAME2(LogValue,0x001b))
   {
      HttpdProcess.SysInputFile = false;
      strcpy (HttpdProcess.SysInput, "PPF?");
   }
   else
   {
      ScratchFab = cc$rms_fab;
      ScratchFab.fab$w_ifi = *(USHORTPTR)(LogValue+2) | FAB$M_PPF_IND;
      ScratchFab.fab$l_nam = &ScratchNam;
      ScratchNam = cc$rms_nam;
      ScratchNam.nam$l_rsa = HttpdProcess.SysInput;
      ScratchNam.nam$b_rss = sizeof(HttpdProcess.SysInput)-1;

      status = sys$display (&ScratchFab, 0, 0);
      if (VMSnok (status)) ErrorExitVmsStatus (status, "sys$display()", FI_LI);

      if (ScratchFab.fab$l_dev & DEV$M_TRM)
      {
         HttpdProcess.SysInputFile = false;
         strcpy (HttpdProcess.SysInput, "TERMINAL");
      }
      else
      {
         HttpdProcess.SysInputFile = true;
         HttpdProcess.SysInput[ScratchNam.nam$b_rsl] = '\0';
      }
   }

   status = sys$trnlnm (0, &LnmProcessDsc, &SysOutputDsc, 0, &LnmItems);
   if (VMSnok (status)) ErrorExitVmsStatus (status, NULL, FI_LI);
   if (!SAME2(LogValue,0x001b))
   {
      HttpdProcess.SysOutputFile = false;
      strcpy (HttpdProcess.SysOutput, "PPF?");
   }
   else
   {
      ScratchFab = cc$rms_fab;
      ScratchFab.fab$w_ifi = *(USHORTPTR)(LogValue+2) | FAB$M_PPF_IND;
      ScratchFab.fab$l_nam = &ScratchNam;
      ScratchNam = cc$rms_nam;
      ScratchNam.nam$l_rsa = HttpdProcess.SysOutput;
      ScratchNam.nam$b_rss = sizeof(HttpdProcess.SysOutput)-1;

      status = sys$display (&ScratchFab, 0, 0);
      if (VMSnok (status)) ErrorExitVmsStatus (status, "sys$display()", FI_LI);

      if (ScratchFab.fab$l_dev & DEV$M_TRM)
      {
         HttpdProcess.SysOutputFile = false;
         strcpy (HttpdProcess.SysOutput, "TERMINAL");
      }
      else
      if (MATCH4(HttpdProcess.SysOutput,"_MPA") &&
          HttpdProcess.SysInput[0] == '_')
      {
         /* i.e. WASD_ROOT:[SRC.UTILS]WASTEE.C */
         HttpdProcess.SysOutputFile = false;
         strcpy (HttpdProcess.SysOutput, "PIPE");
         HttpdProcess.SysInputFile = false;
         strcpy (HttpdProcess.SysInput, "PIPE");
      }
      else
      {
         HttpdProcess.SysOutputFile = true;
         HttpdProcess.SysOutput[ScratchNam.nam$b_rsl] = '\0';
      }
   }

   /* see WASD_ROOT:[SRC.UTILS]WASTEE.C and /PPF */
   status = sys$trnlnm (0, &LnmJobDsc, &WASteeSysInputDsc, 0, &LnmItems);
   if (VMSok (status))
   {
      HttpdProcess.SysInputFile = true;
      strcpy (HttpdProcess.SysInput, LogValue);
      status = sys$trnlnm (0, &LnmJobDsc, &WASteeSysOutputDsc, 0, &LnmItems);
      if (VMSok (status))
      {
         HttpdProcess.SysOutputFile = true;
         strcpy (HttpdProcess.SysOutput, LogValue);
      }
   }

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
"Mode:!UL Uic:!8XL UserName:!&Z PrcNam:!&Z ProcessId:!8XL Grp:!UL \
priv:<63-32>!8XL<31-00>!8XL !&B in:!&Z !&B out:!&Z !&B",
          HttpdProcess.Mode, HttpdProcess.Uic,
          HttpdProcess.UserName, HttpdProcess.PrcNam,
          HttpdProcess.Pid, HttpdProcess.Grp, HttpdProcess.AuthPriv[1],
          HttpdProcess.AuthPriv[0], HttpdProcess.PrivilegedAccount,
          HttpdProcess.SysInput, HttpdProcess.SysInputFile,
          HttpdProcess.SysOutput, HttpdProcess.SysOutputFile);
}

/****************************************************************************/
/*
Check if the /SCRIPT=AS=<username> has been specified, or if not the default
HTTP$NOBODY account, exists and is allowed to be used (not privileged or a
member of the SYSTEM group).  If it is then set the global storage
'HttpdScriptAsUserName' to that username, if not the set it to an invalid user
name to prevent default scripting.  The /SCRIPT=AS=SUBPROCESS keyword forces
subprocess scripting from the command line.
*/ 

int HttpdScriptAs ()

{
   static ulong  Context = -1;
   static ulong  UaiFlags,
                 UaiUic;
   static ulong  UaiPriv [2];

   static struct
   {
      ushort  buf_len;
      ushort  item;
      uchar   *buf_addr;
      ushort  *short_ret_len;
   }
   UaiItems [] =
   {
      { sizeof(UaiFlags), UAI$_FLAGS, &UaiFlags, 0 },
      { sizeof(UaiPriv), UAI$_PRIV, &UaiPriv, 0 },
      { sizeof(UaiUic), UAI$_UIC, &UaiUic, 0 },
      {0,0,0,0}
   };

   int  status;
   char  *uptr;
   static $DESCRIPTOR (UserNameDsc, "");

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdScriptAs()\n");

   /* try any supplied /SCRIPT=AS=, or default scripting account */
   if (CliScriptAs[0])
   {
      if (strsame (CliScriptAs, "SUBPROCESS", -1))
      {
         FaoToStdout ("%HTTPD-W-SCRIPTING, as server account !AZ\n",
                      HttpdProcess.UserName);
         return (SS$_NORMAL);
      }
      UserNameDsc.dsc$a_pointer = uptr = CliScriptAs;
   }
   else
      UserNameDsc.dsc$a_pointer = uptr = "HTTP$NOBODY";
   UserNameDsc.dsc$w_length = strlen(uptr);

   /*  preemptively disable default scripting with an illegal username */
   HttpdScriptAsUserName[0] = '!';
   strzcpy (HttpdScriptAsUserName+1, uptr, sizeof(HttpdScriptAsUserName)-1);

   /* turn on SYSPRV to allow access to SYSUAF records */
   sys$setprv (1, &SysPrvMask, 0, 0);
   status = sys$getuai (0, &Context, &UserNameDsc, &UaiItems, 0, 0, 0);
   sys$setprv (0, &SysPrvMask, 0, 0);

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
"sys$getuai() !&S uic:!8XL flags:!8XL priv:<63-32>!8XL<31-00>!8XL",
                 status, UaiUic, UaiFlags, UaiPriv[1], UaiPriv[0]);

   if (status == RMS$_RNF)
   {
      if (uptr == CliScriptAs)
      {
         /* command-line specified account MUST exist! */
         status = SS$_INVUSER;
         FaoToStdout ("%HTTPD-E-SCRIPTING, as !AZ disabled\n-!&M\n",
                      uptr, status);
         return (status);
      }

      /* the HTTP$NOBODY account doesn't exist, undo preemptive disable */
      HttpdScriptAsUserName[0] = '\0';
      FaoToStdout ("%HTTPD-W-SCRIPTING, as server account !AZ\n",
                   HttpdProcess.UserName);
      return (SS$_NORMAL);
   }

   if (VMSnok (status))
   {
      FaoToStdout ("%HTTPD-E-SCRIPTING, as !AZ disabled\n-!&M\n",
                   uptr, status);
      return (status);
   }

   if (UaiFlags & UAI$M_DISACNT)
   {
      FaoToStdout ("%HTTPD-E-SCRIPTING, as !AZ disabled - DISUSERED\n", uptr);
      return (SS$_INVUSER);
   }

   if ((UaiUic & 0xffff0000) >> 16 <= SysInfo.MaxSysGroup)
   {
      FaoToStdout ("%HTTPD-E-SCRIPTING, as !AZ disabled - SYSTEM GROUP\n",
                   uptr);
      return (SS$_INVUSER);
   }

   if (UaiPriv[0] & ~AveJoePrvMask[0] ||
       UaiPriv[1] & ~AveJoePrvMask[1])
   {
      /* something other than NETMBX and TMPMBX authorized */
      FaoToStdout ("%HTTPD-E-SCRIPTING, as !AZ disabled - PRIVILEGED\n", uptr);
      return (SS$_INVUSER); 
   }

   /* overwrite the preemptive disable */
   strzcpy (HttpdScriptAsUserName, uptr, sizeof(HttpdScriptAsUserName));
   if (strsame (HttpdScriptAsUserName, HttpdProcess.UserName, -1))
      FaoToStdout ("%HTTPD-W-SCRIPTING, as server account !AZ\n",
                   HttpdProcess.UserName);
   else
      FaoToStdout ("%HTTPD-I-SCRIPTING, as !AZ\n", HttpdScriptAsUserName);
   return (SS$_NORMAL); 
}

/*****************************************************************************/
/*
Create a detached server process.  If the /USER= qualifier was used the process
will  have changed it's persona and the process created here will be created
under that user name.  If 'CliParameter' is not supplied it looks for the
startup procedure from 'StartupProcedures' in succession.  If it can't find one
it exits with an error status.  To support startup with a WASD-specific logical
name table (v10.0) it has become necessary to parse the command and output
files to obtain the unconcealed devices.
*/

HttpdDetachServerProcess ()

{
   static char  *StartupProcedures[] =
   {
      "WASD_STARTUP:STARTUP_SERVER.COM",
      "WASD_ROOT:[STARTUP]STARTUP_SERVER.COM",
      "WASD_ROOT:[LOCAL]STARTUP_SERVER.COM",
      "HT_STARTUP:STARTUP_SERVER.COM",
      "HT_ROOT:[STARTUP]STARTUP_SERVER.COM",
      "HT_ROOT:[LOCAL]STARTUP_SERVER.COM",
      NULL
   };

   static struct
   {
      short  flag;
      char  data [1+UAF$S_USERNAME + 1+UAF$S_USERNAME +
                  1+UAF$S_PASSWORD + 1+UAF$S_ACCOUNT];
   } LgiData;
   static $DESCRIPTOR (LgiDataDsc,"");

   static ulong  CrePrcFlags = PRC$M_DETACH;
   static $DESCRIPTOR (LoginOutDsc, "SYS$SYSTEM:LOGINOUT.EXE");
   static char  PrcNam [16];
   static $DESCRIPTOR (PrcNamDsc, PrcNam);
   static $DESCRIPTOR (SysCommandDsc, "");
   static $DESCRIPTOR (SysOutputDsc, "");
   static ushort  Length;

   int  idx, status;
   uint  ProcessPid;
   ushort  slen;
   char  *cptr, *sptr, *zptr;
   char  LogFileName [256],
         SysCommand [256];
   ODS_STRUCT  SysCommandOds,
               SysOutputOds;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdDetachServerProcess()");

   sys$gettim (&HttpdTime64);
   sys$numtim (&HttpdTime7, &HttpdTime64);

   if (CliParameter[0])
      cptr = CliParameter;
   else
   {
      /* look for one of several possible startup procedures */
      for (idx = 0; cptr = StartupProcedures[idx]; idx++)
      {
         if (VMSok (status = OdsFileExists (NULL, cptr))) break;
         if (status != RMS$_DEV && status != RMS$_DNF && status != RMS$_FNF)
            break;
      }
      if (VMSnok (status))
      {
         if (!cptr) cptr = "STARTUP_SERVER.COM";
         ErrorExitVmsStatus (status, cptr, FI_LI);
      }
   }

   OdsStructInit (&SysCommandOds, true);
   OdsParse (&SysCommandOds, cptr, strlen(cptr), NULL, 0,
             NAM$M_NOCONCEAL | NAM$M_SYNCHK, 0, 0);

   SysCommandDsc.dsc$a_pointer = SysCommandOds.ExpFileName;
   SysCommandDsc.dsc$w_length = SysCommandOds.ExpFileNameLength;

   FaoToBuffer (LogFileName, sizeof(LogFileName), &Length,
                "!AZ!AZ_!4ZL!2ZL!2ZL!2ZL!2ZL!2ZL.LOG",
                v10orPrev10(CONFIG_SERVER_LOGS,-1),
                SysInfo.NodeName,
                HttpdTime7[0], HttpdTime7[1], HttpdTime7[2],
                HttpdTime7[3], HttpdTime7[4], HttpdTime7[5],
                HttpdTime7[6]);

   OdsStructInit (&SysOutputOds, true);
   OdsParse (&SysOutputOds, LogFileName, Length, NULL, 0,
             NAM$M_NOCONCEAL | NAM$M_SYNCHK, 0, 0);

   SysOutputDsc.dsc$a_pointer = SysOutputOds.ExpFileName;
   SysOutputDsc.dsc$w_length = SysOutputOds.ExpFileNameLength;

   if (InstanceEnvNumber > 1)
   {
      /* the starting HTTPd process will look for and parse this number */
      FaoToBuffer (PrcNam, sizeof(PrcNam), &Length,
                   "!ULWASD:starting", InstanceEnvNumber);
      PrcNam[PrcNamDsc.dsc$w_length = Length] = '\0';
   }
   else
   {
      PrcNamDsc.dsc$a_pointer = "WASD:starting";
      PrcNamDsc.dsc$w_length = 13;
   }

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchDataFormatted ("$CREPRC !UL !&Z !&Z !&Z !AZ !AZ !&B\n",
                          ProcessPriority,
                          LoginOutDsc.dsc$a_pointer,
                          SysCommandDsc.dsc$a_pointer,
                          SysOutputDsc.dsc$a_pointer,
                          CliUserName,
                          PrcNamDsc.dsc$a_pointer,
                          HttpdNetworkMode);

   if (CliNetworkMode ||
       HttpdNetworkMode)
   {
      /*********************************/
      /* create "network" mode process */
      /*********************************/
      
      if (CliUserName[0])
         cptr = CliUserName;
      else
         cptr = HttpdProcess.UserName;
      memset (&LgiData, 0, sizeof(LgiData));
      LgiData.flag = LGI$M_NET_PROXY;
      idx = 0;
      LgiData.data[idx] = strlen(cptr);
      memcpy (&LgiData.data[idx+1], cptr, LgiData.data[idx]);
      idx += LgiData.data[idx] + 1;
      LgiData.data[idx++] = 0;
      LgiData.data[idx++] = 0;
      LgiData.data[idx++] = 0;
      LgiDataDsc.dsc$a_pointer = &LgiData;
      LgiDataDsc.dsc$w_length = sizeof(LgiData.flag) + idx;
      CrePrcFlags = PRC$M_DETACH | PRC$M_NETWRK | PRC$M_NOPASSWORD;
      
      status = sys$creprc (&ProcessPid,
                           &LoginOutDsc,
                           /* composite SYS$INPUT and log file name */
                           &SysCommandDsc,
                           /* proxy login data structure */
                           &LgiDataDsc,
                           /* SYS$NET, which must be redirected to */
                           &SysOutputDsc, 0, 0,
                           &PrcNamDsc,
                           ProcessPriority, 0, 0,
                           CrePrcFlags, 0, 0);
   }
   else
   {
      /***********************/
      /* create "other" mode */
      /***********************/

      if (CliUserName[0])
      {
         /* needs to be done explicitly in case PERSONA_MACRO is in use */
         PersonaInit ();
         if (VMSnok (status = PersonaAssume (CliUserName)))
            exit (status);
      }

      status = sys$creprc (&ProcessPid,
                           &LoginOutDsc,
                           &SysCommandDsc,
                           &SysOutputDsc, 0, 0, 0,
                           &PrcNamDsc,
                           ProcessPriority, 0, 0,
                           CrePrcFlags, 0, 0);

      /* needs to be done explicitly in case PERSONA_MACRO is in use */
      if (CliUserName[0]) PersonaAssume (NULL);
   }

   if (VMSnok (status))
      ErrorExitVmsStatus (status, "sys$creprc()", FI_LI);

   FaoToStdout (
"%HTTPD-S-PROC_ID, identification of created process is !8XL\n",
      ProcessPid);

   return (SS$_NORMAL);
}

/*****************************************************************************/
/*
Exit the HTTP server, via this declared exit handler.
Use vanilla output in case other routines are implicated.
*/

HttpdExit (ulong *ExitStatusPtr)

{
   static $DESCRIPTOR (ErrorFaoDsc, "%HTTPD-F-EXIT, !AZ, !AZ %X!8XL\r\n-!AZ\0");
   static $DESCRIPTOR (DateTimeFaoDsc, "!20%D\0");

   static char  DateTime [32];
   static $DESCRIPTOR (DateTimeDsc, DateTime);

   int  status;
   ushort  Length;
   ulong  ExitStatus;
   char  MsgString [256] = "?";
   $DESCRIPTOR (MsgStringDsc, MsgString); 
   $DESCRIPTOR (StringDsc, ""); 
   struct invo_context_blk icb;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdExit() !&S", *ExitStatusPtr);

   /* exit handler executes in non-AST context so disable */
   sys$setast (0);

   ExitStatus = *ExitStatusPtr;

   /* run down any script processes associated with script processing */
   DclExit ();

   /* ensure any proxy verify records still in use are cleared */
   ProxyVerifyInit ();

   /* Q&D flush SYS$OUTPUT */
   fsync (STDOUT_FILENO);

   if (LoggingEnabled)
   {
      /* provide a server exit entry */
      Logging (NULL, LOGGING_END);
   }

   /* don't worry about locking the section with this last gasp */
   AccountingPtr->LastExitStatus = ExitStatus;
   AccountingPtr->LastExitPid = HttpdProcess.Pid;
   sys$gettim (&AccountingPtr->LastExitTime64);
   sys$fao (&DateTimeFaoDsc, NULL, &DateTimeDsc, 0);

   status = sys$getmsg (ExitStatus, &Length, &MsgStringDsc, 15, 0);
   if (VMSok (status)) MsgString[Length] = '\0';

   if (VMSnok (ExitStatus))
   {
      /**************/
      /* error exit */
      /**************/

      StringDsc.dsc$w_length = sizeof(HttpdGblSecPtr->StatusMessage)-1;
      StringDsc.dsc$a_pointer = HttpdGblSecPtr->StatusMessage;

      sys$fao (&ErrorFaoDsc, NULL, &StringDsc,
               DateTime, HttpdProcess.PrcNam, ExitStatus, MsgString+1);

      /* record server event */
      GraphActivityEvent (ACTIVITY_EXIT_ERROR);

      /* report to process log */
      fprintf (stdout, "%%HTTPD-F-EXIT, %s, %s %%X%08.08X\n",
               DateTime, HttpdProcess.PrcNam, ExitStatus);

      if (ExitStatus != SS_W_CONTROLY)
      {
         /* add traceback information */
         int  SanityCheck = 100;
#ifdef __ALPHA
         lib$get_curr_invo_context (&icb);
         while (lib$get_prev_invo_context (&icb),
                !icb.libicb$v_bottom_of_stack && SanityCheck--)
            fprintf (stdout, "-HTTPD-F-TRACE, %08.08X%08.08X\n",
                     icb.libicb$q_program_counter[1],
                     icb.libicb$q_program_counter[0]);
#endif
#ifdef __ia64
         lib$i64_init_invo_context (&icb, LIBICB$K_INVO_CONTEXT_VERSION);
   
         lib$i64_get_curr_invo_context (&icb);
            while (lib$i64_get_prev_invo_context (&icb),
                   !icb.libicb$v_bottom_of_stack && SanityCheck--)
            fprintf (stdout, "-HTTPD-F-TRACE, %08.08X%08.08X\n",
                     ((ULONGPTR)&icb.libicb$ih_pc)[1],
                     ((ULONGPTR)&icb.libicb$ih_pc)[0]);
#endif
#ifdef __x86_64
         lib$x86_init_invo_context (&icb, LIBICB$K_INVO_CONTEXT_VERSION);
   
         lib$x86_get_curr_invo_context (&icb);
            while (lib$x86_get_prev_invo_context (&icb),
                   !icb.libicb$v_bottom_of_stack && SanityCheck--)
            fprintf (stdout, "-HTTPD-F-TRACE, %08.08X%08.08X\n",
                     ((ULONGPTR)&icb.libicb$ih_ip)[1],
                     ((ULONGPTR)&icb.libicb$ih_ip)[0]);
#endif
         /* list current and history list requests */
         RequestDump ();
      }
   }

   if (VMSok (ExitStatus))
   {
      /***************/
      /* normal exit */
      /***************/

      /* record server exit event */
      GraphActivityEvent (ACTIVITY_EXIT);

      fprintf (stdout, "%%HTTPD-I-EXIT, %s, %s %%X%08.08X\n-%s\n",
               DateTime, HttpdProcess.PrcNam, ExitStatus, MsgString+1);
#if WATCH_MOD
      fputs (WatchServerQuotas(0), stdout);
      HttpdStackTrace ("exit()", FI_LI);
      RequestDump ();
#endif
   }

   if (OpcomMessages)
   {
      /*********/
      /* opcom */
      /*********/

      struct
      {
         ulong  TargetType;
         ulong  RequestId;
         char  MsgText [986+1];
      } OpcomMsg;
      $DESCRIPTOR (OpcomDsc, "");
      $DESCRIPTOR (OpcomFaoDsc, "Process !AZ reports\r\n"
                                "%HTTPD-!AZ-EXIT, !AZ, %X!8XL\r\n-!AZ");

      OpcomDsc.dsc$a_pointer = &OpcomMsg.MsgText;
      OpcomDsc.dsc$w_length = sizeof(OpcomMsg.MsgText)-1;
      status = sys$fao (&OpcomFaoDsc, &Length, &OpcomDsc,
                        HttpdProcess.PrcNam,
                        VMSnok(ExitStatus) ? "F" : "I",
                        DateTime, ExitStatus, MsgString+1);
      /* errors noticed uses vanilla output (for the same reasons) */
      if (VMSnok (status)) FaoErrorNoticed (status, NULL, FI_LI);

      OpcomMsg.TargetType = OPC$_RQ_RQST + ((OpcomTarget & 0xffffff) << 8);
      OpcomMsg.RequestId = 0;

      OpcomDsc.dsc$a_pointer = &OpcomMsg;
      OpcomDsc.dsc$w_length = Length + 8;

      /* an error exit is ALWAYS reported via OPCOM */
      if (VMSnok (ExitStatus))
         status = sys$sndopr (&OpcomDsc, 0);
      else
      /* others will be reported is enabled */
      if (OpcomMessages & OPCOM_HTTPD)
         status = sys$sndopr (&OpcomDsc, 0);
      else
         status = SS$_NORMAL;
      /* errors noticed uses vanilla output (for the same reasons) */
      if (VMSnok (status)) FaoErrorNoticed (status, NULL, FI_LI);
   }

   InstanceStatusExit (ExitStatus);

   if (VMSnok (ExitStatus)) fputs ("-HTTPD-F-ADIEU, ...\n", stdout);

   fflush (stdout);

   /* anything that needs to be explicitly done during instance shutdown */
   InstanceExit ();

   /* reenable user mode ASTs */
   sys$setast (1);
}

/*****************************************************************************/
/*
Trace of call stack for debug purposes.  Include call in code to use :-)
*/

void HttpdStackTrace
(
char *title,
char *module,
int line
)
{
   static char  buf [32];
   static $DESCRIPTOR (TimeBufDsc, buf);
   static $DESCRIPTOR (TimeFaoDsc, "!8%T\0");

   int  status;
   struct invo_context_blk icb;

   /*********/
   /* begin */
   /*********/

   sys$fao (&TimeFaoDsc, 0, &TimeBufDsc, 0);

   fprintf (stdout, "TRACE+++++++++++ %s %s:%d %s\n", title, module, line, buf);

   fflush (stdout);

#ifdef __ALPHA
   lib$get_curr_invo_context (&icb);
   while (lib$get_prev_invo_context (&icb), !icb.libicb$v_bottom_of_stack)
      fprintf (stdout, "%08.08X%08.08X\n",
               icb.libicb$q_program_counter[1],
               icb.libicb$q_program_counter[0]);
#endif
#ifdef __ia64
   lib$i64_init_invo_context (&icb, LIBICB$K_INVO_CONTEXT_VERSION);

   lib$i64_get_curr_invo_context (&icb);
   while (lib$i64_get_prev_invo_context (&icb), !icb.libicb$v_bottom_of_stack)
      fprintf (stdout, "%08.08X%08.08X\n",
               ((ULONGPTR)&icb.libicb$ih_pc)[1],
               ((ULONGPTR)&icb.libicb$ih_pc)[0]);
#endif
#ifdef __x86_64
   lib$x86_init_invo_context (&icb, LIBICB$K_INVO_CONTEXT_VERSION);

   lib$x86_get_curr_invo_context (&icb);
   while (lib$x86_get_prev_invo_context (&icb), !icb.libicb$v_bottom_of_stack)
      fprintf (stdout, "%08.08X%08.08X\n",
               ((ULONGPTR)&icb.libicb$ih_ip)[1],
               ((ULONGPTR)&icb.libicb$ih_ip)[0]);
#endif

   fprintf (stdout, "+++++++++++TRACE\n");

   fflush (stdout);
}

/*****************************************************************************/
/*
Collect alignment fault statistics.

Intended to be used as a tool for the WASD developer to monitor alignment
faults (expensive on Alpha and VERY expensive on Itanium) and track down (and
perhaps remedy) the code sections generating those faults.

Data is collected into an array of PC addresses masked to aggregate those
addresses into groups (conserving the number of actual entries).  The PCs thus
generated allow the linker map and then associated compiler lists to be used to
"zero-in" on sections of code generating alignments faults.

Collection and reporting is enabled by default but can be modified using the
command-line /DO=ALIGN=START, /DO=ALIGN=STOP and /DO=ALIGN=ZERO.  The control
string also allows three data collection parameters to be set (which also
starts collection) /DO=ALIGN=<data-kB>[,<item-max>[,<PC-mask-hex>]].

When WASD is correctly coded there should be no alignment faults (or close to
none perhaps due to those lurking in uncommonly traversed code paths) so it
might be reassuring that an alignment fault report indicating none is really
working!  The /DO=ALIGN=FAULT=<integer> will generate alignment faults whenever
the data collection function is called (usually at least once per second). 
These will be reported in the HTTPD module (of course). Use /DO=ALIGN=FAULT=0
to disabled fault generation. 
*/

void* HttpdAlignFault (char *ControlString)

{
#define ALIGN_BUFFER_SIZE 64  /* kByte */
#define ALIGN_PCS_MAX 128

   static int  GenerateFault,
               GetBufferSize,
               ItemArraySize,
               ItemCount,
               ItemMax,
               ItemOverflow,
               PCmask,
               ReportBufferSize,
               ReportOverflow,
               StartTickSecond;
   static uchar  *GetBufferPtr,
                         *ReportBufferPtr;
   static struct FaultDataStruct  ItemData;
   static struct FaultAccumStruct  *ItemArrayPtr;
                         
   int  idx, status;
   ulong  pc;
   ulong  GetBufferLength = 0;
   uchar  *afrptr, *zfrptr;
   char  *cptr;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdAlignFault() !&Z", ControlString);

   if (!ControlString)
   {
      /**********************/
      /* get and accumulate */
      /**********************/

      if (!HttpdAlignFaultReport) return (NULL);

      /* generate reassurement faults for quiet reports */
      for (idx = 0; idx < GenerateFault; idx++)
         ((ushort*)(GetBufferPtr+1))[idx]++;

      status = sys$get_align_fault_data (GetBufferPtr,
                                         GetBufferSize,
                                         &GetBufferLength);
      if (VMSnok (status))
         ErrorNoticed (NULL, status, "sys$get_align_fault_data()", FI_LI);

      if (WATCH_MODULE(WATCH_MOD__OTHER))
         WatchThis (WATCHALL, WATCH_MOD__OTHER, "!UL !UL !UL",
                    ReportBufferSize, GetBufferSize, GetBufferLength);

      /* (educated) guess as to whether the storage was exhausted */
      if (GetBufferLength >= GetBufferSize - AFR$K_USER_LENGTH)
         ReportOverflow++;

      zfrptr = (afrptr = GetBufferPtr) + GetBufferLength;
      while (afrptr < zfrptr)
      {
         HttpdAlignFaultCount++;

         pc = ((struct afrdef*)afrptr)->afr$l_fault_pc_l;
         pc = pc & PCmask;

         for (idx = 0; idx < ItemCount; idx++)
            if (ItemArrayPtr[idx].pc == pc) break;

         if (idx < ItemCount)
            ItemArrayPtr[idx].cnt++;
         else
         if (ItemCount < ItemMax)
         {
            ItemArrayPtr[ItemCount].pc = pc;
            ItemArrayPtr[ItemCount].cnt = 1;
            ItemCount++;
         }
         else
            ItemOverflow++;

         afrptr += AFR$C_USER_LENGTH;
      }

      /* populate the data structure to be returned */
      ItemData.ItemArray = ItemArrayPtr;
      ItemData.ItemCount = ItemCount;
      ItemData.ItemMax = ItemMax;
      ItemData.ItemOverflow = ItemOverflow;
      ItemData.GetBufferSize = GetBufferSize;
      ItemData.PCmask = PCmask;
      ItemData.ReportBufferSize = ReportBufferSize;
      ItemData.ReportOverflow = ReportOverflow;
      ItemData.StartTickSecond = StartTickSecond;

      return (&ItemData);
   }


   cptr = ControlString;

   if (strsame (cptr, "START", -1) ||
       isdigit(*cptr))
   {
      /********************/
      /* start collecting */
      /********************/

      if (HttpdAlignFaultReport) return (NULL);

      GenerateFault = HttpdAlignFaultCount = ItemCount =
         ItemMax = ItemOverflow = ReportOverflow = 0;
      StartTickSecond = HttpdTickSecond;

      if (isdigit(*cptr)) ReportBufferSize = atoi(cptr);
      if (ReportBufferSize < ALIGN_BUFFER_SIZE)
         ReportBufferSize = ALIGN_BUFFER_SIZE;
      ReportBufferSize *= 1024;

      while (*cptr && isdigit(*cptr)) cptr++;
      while (*cptr && !isdigit(*cptr)) cptr++;
      ItemMax = atoi(cptr);
      if (ItemMax < ALIGN_PCS_MAX) ItemMax = ALIGN_PCS_MAX;

      /* two hex digits (256 addresses, 8 bits) of mask can be specified */
      while (*cptr && isdigit(*cptr)) cptr++;
      while (*cptr && !isxdigit(*cptr)) cptr++;
      if (*cptr)
      {
         PCmask = strtol(cptr,NULL,16);
         PCmask = (PCmask & 0xff) | 0xffffff00;
      }
      else
//         PCmask = 0xfffffff0;
         PCmask = 0xffffffff;

      ReportBufferPtr = VmGet (ReportBufferSize);

      ItemArraySize = sizeof(struct FaultAccumStruct) * ItemMax;
      ItemArrayPtr = (struct FaultAccumStruct*) VmGet (ItemArraySize);

      GetBufferSize = ReportBufferSize;
      GetBufferPtr = VmGet (GetBufferSize);

      status = sys$start_align_fault_report (AFR$C_BUFFERED,
                                             ReportBufferPtr,
                                             ReportBufferSize);
      if (VMSok (status))
      {
         HttpdAlignFaultReport = true;
         FaoToStdout ("%HTTPD-I-ALIGN, start collecting \
alignment faults (!ULkB,!UL,0x!8XL)\n",
                      ReportBufferSize/1024, ItemMax, PCmask);
      }
      else
      {
         VmFree (GetBufferPtr, FI_LI);
         VmFree (ItemArrayPtr, FI_LI);
         VmFree (ReportBufferPtr, FI_LI);
         GetBufferSize = HttpdAlignFaultCount =
            ItemArraySize = ReportBufferSize = 0;
         GetBufferPtr = ItemArrayPtr = ReportBufferPtr = NULL;
         ErrorNoticed (NULL, status,
                       "sys$start_align_fault_report()", FI_LI);
      }
   }
   else
   if (strsame (cptr, "STOP", -1))
   {
      /*******************/
      /* stop collecting */
      /*******************/

      if (!HttpdAlignFaultReport) return (NULL);

      status = sys$stop_align_fault_report ();
      if (VMSok (status))
      {
         HttpdAlignFaultReport = false;
         VmFree (GetBufferPtr, FI_LI);
         VmFree (ItemArrayPtr, FI_LI);
         VmFree (ReportBufferPtr, FI_LI);
         GetBufferSize = HttpdAlignFaultCount = 
            ItemArraySize = ReportBufferSize = 0;
         GetBufferPtr = ItemArrayPtr = ReportBufferPtr = NULL;
         FaoToStdout ("%HTTPD-I-ALIGN, stop collecting alignment faults\n");
      }
      else
         ErrorNoticed (NULL, status, "sys$stop_align_fault_report()", FI_LI);
   }
   else
   if (strsame (cptr, "ZERO", -1))
   {
      /*******************/
      /* zero statistics */
      /*******************/

      if (!HttpdAlignFaultReport) return (NULL);

      HttpdAlignFaultCount = ItemCount = ItemOverflow = ReportOverflow = 0;
      StartTickSecond = HttpdTickSecond;
      memset (ItemArrayPtr, 0, ItemArraySize);
   }
   else
   if (strsame (cptr, "FAULT=", 6))
   {
      /*******************/
      /* generate faults */
      /*******************/

      GenerateFault = atoi(cptr+6);
   }

   return (NULL);
}

/*****************************************************************************/
/*
Elementary bubble sort with PC ascending.
Just makes the alignment fault PC listing a little more intuitive.
*/

HttpdAlignSort
(
struct FaultAccumStruct *ItemArrayPtr,
int ItemCount
)
{
   int  cnt, idx1, idx2;
   ulong  pc;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdAlignSort()");

   for (idx1 = 0; idx1 < ItemCount; idx1++)
   {
      for (idx2 = idx1+1; idx2 < ItemCount; idx2++)
      {
         if (ItemArrayPtr[idx1].pc < ItemArrayPtr[idx2].pc) continue;
         pc = ItemArrayPtr[idx1].pc;
         cnt = ItemArrayPtr[idx1].cnt;
         ItemArrayPtr[idx1].pc = ItemArrayPtr[idx2].pc;
         ItemArrayPtr[idx1].cnt = ItemArrayPtr[idx2].cnt;
         ItemArrayPtr[idx2].pc = pc;
         ItemArrayPtr[idx2].cnt = cnt;
      }
   }
}

/*****************************************************************************/
/*
Report on the statistics gathered by HttpAlignFault().
If logical name WASD_ALIGN_MAP points to a linker map the also provides the
code module containing the PC and its offset.
*/ 

HttpdAlignReport (REQUEST_STRUCT *rqptr)

{
   static char  BeginTableFao [] =
"<p><table class=\"ctgry\">\n\
<tr><td>\n\
<table class=\"rghtrght\">\n";

   static char  HeadFao [] =
"!AZ<th></th><th><u>PC</u></th>\
<th><u>Count</u></th>";

   static char  ItemFao [] =
"!AZ<th>!UL.</th><td><tt>!AZ</tt></td><td>!UL</td>";

   static char  ItemTotalFao [] =
"<tr><th colspan=\"2\">Total:</th><td>!UL</td></tr>\n\
<tr><th colspan=\"2\">Per-Second:</th><td>!UL</td></tr>\n";

   static char  EndTableFao [] =
"</table>\n\
</td></tr>\n\
</table>\n";

   static char  EndPageFao [] =
"<p>PC mask:&nbsp; 0x!8XL\n\
<br>PCs:&nbsp; !UL max&nbsp; (overflow:!UL)\n\
<br>Buffer:&nbsp; !ULkB&nbsp; (overflow:!UL)\n\
</body>\n\
</html>\n";

   static struct FaultDataStruct  ItemData;

   int  cnt, idx1, idx2,
        ColStep,
        ItemCount,
        NumbCols;
   uint  SecondsElapsed;
   struct FaultDataStruct  *ItemDataPtr;
   struct FaultAccumStruct  *ItemArrayPtr = NULL;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdAlignReport()");

   ItemDataPtr = HttpdAlignFault (NULL);

   AdminPageTitle (rqptr, "Alignment Fault Report");

   if (ItemDataPtr)
   {
      ItemArrayPtr = ItemDataPtr->ItemArray;
      ItemCount = ItemDataPtr->ItemCount;
      HttpdAlignSort (ItemArrayPtr, ItemCount);

      if (ItemCount < 15)
         NumbCols = 1;
      else
      if (ItemCount < 80)
         NumbCols = 3;
      else
      if (ItemCount < 160)
         NumbCols = 4;
      else
         NumbCols = 5;
      ColStep = ItemCount / NumbCols;
      if (ItemCount % NumbCols) ColStep++;

      FaoToNet (rqptr, BeginTableFao);
      if (HttpdAlignFaultCount)
      {
         FaoToNet (rqptr, "<tr>");
         for (cnt = 0; cnt < NumbCols; cnt++)
            FaoToNet (rqptr, HeadFao, cnt ? "<th></th>" : "");
         FaoToNet (rqptr, "</tr>\n");
      }
      for (idx1 = 0; idx1 * NumbCols < ItemCount; idx1++)
      {
         FaoToNet (rqptr, "<tr>");
         for (cnt = 0; cnt < NumbCols; cnt++)
         {
            idx2 = idx1 + (ColStep * cnt);
            if (idx2 >= ItemCount) break;
            FaoToNet (rqptr, ItemFao,
                      cnt ? "<td></td>" : "",
                      idx2+1,
                      HttpdAlignModule(ItemArrayPtr[idx2].pc),
                      ItemArrayPtr[idx2].cnt);
         }
         FaoToNet (rqptr, "</tr>\n");
      }
      SecondsElapsed = HttpdTickSecond - ItemDataPtr->StartTickSecond;
      if (SecondsElapsed)
         FaoToNet (rqptr, ItemTotalFao,
                   HttpdAlignFaultCount,
                   HttpdAlignFaultCount / SecondsElapsed);
      FaoToNet (rqptr, EndTableFao);

      /* reset the module function */
      HttpdAlignModule (0);
   }
   else
      ItemDataPtr = &ItemData;

   FaoToNet (rqptr, EndPageFao,
             ItemDataPtr->PCmask,
             ItemDataPtr->ItemMax, ItemDataPtr->ItemOverflow,
             ItemDataPtr->ReportBufferSize/1024, ItemDataPtr->ReportOverflow);

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/html", &rqptr->NetWriteBufferDsc);

   AdminEnd (rqptr);
}

/*****************************************************************************/
/*
Return a pointer to a static buffer with either the PC parameter or if the file
WASD_ALIGN_MAP (logical name) exists the PC with the module associated with
that PC and the offset into that module.  Must be called with PC zero to free
allocated resources.
*/

char* HttpdAlignModule (ulong pc)

{
   static BOOL  LoadMap = true;
   static char  *CodePtr;
   static char  PcData [64];
   static ODS_STRUCT  MapFileOds;

   int  status;
   ulong  end, start;
   char  *cptr, *sptr, *zptr;
   char  ModuleName [32];

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdAlignModule() !8XL", pc);

   if (!pc)
   {
      if (MapFileOds.DataLinePtr) VmFree (MapFileOds.DataLinePtr, FI_LI);
      memset (&MapFileOds, 0, sizeof(ODS_STRUCT));
      CodePtr = NULL;
      LoadMap = true;
      return (NULL);
   }

   FaoToBuffer (PcData, sizeof(PcData), 0, "!8XL", pc);

   if (LoadMap)
   {
      LoadMap = false;
      status = OdsLoadTextFile (&MapFileOds,
                                ProtocolHttpsAvailable ?
                                "WASD_ROOT:[SRC.HTTPD]HTTPD_SSL.MAP" :
                                "WASD_ROOT:[SRC.HTTPD]HTTPD.MAP");
      if (VMSnok(status))
         status = OdsLoadTextFile (&MapFileOds, "WASD_ALIGN_MAP");
      if (VMSnok (status)) return (PcData);
      if (CodePtr = strstr (MapFileOds.DataPtr, "$CODE$"))
         if (cptr = strstr (CodePtr, "$BSS$"))
            *cptr = '\0';
   }

   if (!CodePtr) return (PcData);

   start = end = 0;
   ModuleName[0] = '\0';
   cptr = CodePtr;
   while (*cptr)
   {
      start = end = 0;
      while (*cptr && *cptr != '\n') cptr++;
      if (!*cptr) break;
      cptr++;
      if (!isspace(*cptr) && !strncmp (cptr, "$CODE$", 6)) continue;
      while (*cptr && isspace(*cptr) && *cptr != '\n') cptr++;
      if (*cptr == '\n') continue;
      ModuleName[0] = '\0';
      zptr = (sptr = ModuleName) + sizeof(ModuleName)-1;      
      while (*cptr && !isspace(*cptr) && *cptr != '\n' && sptr < zptr)
         *sptr++ = *cptr++;
      *sptr = '\0';
      while (*cptr && !isspace(*cptr) && *cptr != '\n') cptr++;
      while (*cptr && isspace(*cptr) && *cptr != '\n') cptr++;
      if (!isxdigit(*cptr)) continue;
      start = strtol(cptr,NULL,16);
      while (*cptr && !isspace(*cptr) && *cptr != '\n') cptr++;
      while (*cptr && isspace(*cptr) && *cptr != '\n') cptr++;
      if (!isxdigit(*cptr)) continue;
      end = strtol(cptr,NULL,16);
      if (pc >= start && pc <= end) break;
   }

   if (start && end)
      FaoToBuffer (PcData, sizeof(PcData), 0,
                   "!8XL<br>!AZ+!8XL", pc, ModuleName, pc-start);

   return (PcData);
}

/*****************************************************************************/
/*
*/

int HttpdOnControlY (BOOL ControlY)

{
   static BOOL  Disabled = false;
   static ulong  Mask = LIB$M_CLI_CTRLY,
                 OldMask;
   static ushort  TTChannel = 0;
   static IO_SB  IOsb;

   int  status;
   $DESCRIPTOR (TTDsc, "TT:");

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdOnControlY() !&B", ControlY);

   if (ControlY) exit (SS_W_CONTROLY);

   if (!TTChannel)
      if (VMSnok (status = sys$assign (&TTDsc, &TTChannel, 0, 0, 0)))
         return (status);

   status = sys$qiow (EfnWait, TTChannel, IO$_SETMODE | IO$M_CTRLYAST, &IOsb,
                      0, 0, &HttpdOnControlY, true, PSL$C_USER, 0, 0, 0);
   if (VMSok (status)) status = IOsb.Status;
   if (VMSnok (status)) return (status);

   status = sys$qiow (EfnWait, TTChannel, IO$_SETMODE | IO$M_CTRLCAST, &IOsb,
                      0, 0, &HttpdOnControlY, true, PSL$C_USER, 0, 0, 0);
   if (VMSok (status)) status = IOsb.Status;
   if (VMSnok (status)) return (status);

   if (!Disabled)
   {
      Disabled = true;
      return (lib$disable_ctrl (&Mask, &OldMask));
   }
   else
      return (status);
}

/*****************************************************************************/
/*
Server exit if more than expected privileges.
*/

void HttpdCheckPriv
(
char *SourceModuleName,
int SourceLineNumber
)
{
   ulong  *pmptr;
   char  Buffer [128];

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdCheckPriv()");

   if (!(pmptr = HttpdExpectedPriv())) return;

   HttpdStackTrace ("HttpdCheckPriv()", FI_LI);
   FaoToBuffer (Buffer, sizeof(Buffer), 0,
                "privilege sanity check: <63-32>!8XL<31-00>!8XL",
                pmptr[0], pmptr[0]);
   ErrorExitVmsStatus (SS$_BUGCHECK, Buffer,
                       SourceModuleName, SourceLineNumber);
}

/*****************************************************************************/
/*
As the code gets more complex it's becoming increasingly possible a coding or
design error will leave privileges turned on somewhere.  To help detect any
such problem ensure everthing's off that's supposed to be off.
*/

ulong* HttpdExpectedPriv ()

{
   static ulong  CurrPriv [2];

   int  status;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdExpectedPriv()");

   if (VMSnok (status = sys$setprv (1, &AveJoePrvMask, 0, &CurrPriv)))
      ErrorExitVmsStatus (status, "sys$setprv()", FI_LI);

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchDataFormatted ("!&X !&X\n", CurrPriv[1], CurrPriv[0]);

   /* if only NETMBX and TMPMBX enabled then ok */
   if (!(CurrPriv[0] & ~AveJoePrvMask[0] ||
         CurrPriv[1] & ~AveJoePrvMask[1])) return (NULL);

#if OPERATE_WITH_SYSPRV
   /* if operating with SYSPRV and it's enabled then ok */
   if (OperateWithSysPrv &&
       (CurrPriv[0] & ~AveJoePrvMask[0] == SysPrvMask[0])) return (NULL);
#endif

   return (CurrPriv);
}

/*****************************************************************************/
/*
This function calls itself (via a timer AST) every second or every sixty
seconds.  It updates the 'HttpdTickSecond' global storage by using system time
as a baseline (which works around any latency or cluster transition issues,
etc.)  This counts upwards across year boundaries.  It then calls the various
"activity supervisors" within the server.  If any of these has requests or
tasks still to supervise, or other periodic activities to perform,  they do it
and return a true which indicates the per-second ticker should continue to
tick.  Part of the duty of this function is to update the global storage
'HttpdTickSecond' which indicates the timeline progress of the server as well
as is used by various sections to set expiry points (marked by these global
"seconds").  Per-second ticking is initiated by any one of a small number of
code points calling this function with a zero value parameter upon the first
request processed in an otherwise quiescent server ('HttpdTicking' is false).
*/

HttpdTick (long reqidt)

{
   static ushort  PrevDay = -1,
                  PrevHour = -1,
                  PrevMinute = -1;

   int  status;
   char  *cptr;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdTick() !&X", reqidt);

   sys$gettim (&HttpdTime64);
   sys$numtim (&HttpdTime7, &HttpdTime64);
   HttpdTickSecond = HttpdGetTickSecond();

   if (!HttpdStartTime64)
   {
      /* initialise */
      sys$gettim (&HttpdStartTime64);
      TimeSetHttpdUTC ();
   }

   if (PrevDay != HttpdTime7[2])
   {
      PrevDay = HttpdTime7[2];
      lib$day_of_week (&HttpdTime64, &HttpdDayOfWeek);
   }

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "TICK !UL !%D", HttpdTickSecond, &HttpdTime64);

   if (Watch.RequestPtr) WatchWrite (NULL, 0);

   if (HttpdServerStartup)
      HttpdTicking = true;
   else
   {
      InstanceStatusUpdate (NULL);

      /* (if active) accumulate alignment fault data */
      if (HttpdAlignFaultReport) HttpdAlignFault (NULL);

      HttpdTicking = false;
      if (HttpdSupervisor ()) HttpdTicking = true;
      if (NetAcceptSupervisor ()) HttpdTicking = true;
      if (Http2Supervisor ()) HttpdTicking = true;
      if (InstanceSupervisor ()) HttpdTicking = true;
      if (ProxyNetConnectSupervisor (-1)) HttpdTicking = true;
      if (DclSupervisor (-1)) HttpdTicking = true;
      if (DECnetSupervisor (-1)) HttpdTicking = true;

      if (PrevMinute != HttpdTime7[4])
      {
         /****************/
         /* every minute */
         /****************/

         if (PrevMinute >= 0)
         {
            /* after the first minute */
            TimeSetHttpdUTC ();
            VmCheckPgFlLimit ();
            sysPlusRmi ((REQUEST_STRUCT*)-1);
            sysPlusNet ((REQUEST_STRUCT*)-1);
#if !WATCH_MOD
            if (SysInfo.ClusterMember)
#endif
            {
               sysPlusScs ((REQUEST_STRUCT*)-1);
               sysPlusMscp ((REQUEST_STRUCT*)-1);
            }
#if WATCH_MOD
            NetTestSupervisor ();
#endif
            ThrottleMonitorReset ();
            TcpIpHostCacheSupervisor (HttpdTickSecond);
            Logging (NULL, LOGGING_FLUSH);
         }
         PrevMinute = HttpdTime7[4];

         if (PrevHour != HttpdTime7[3])
         {
            /**************/
            /* every hour */
            /**************/

            if (PrevHour >= 0)
            {
               /* after the first hour */
               Logging (NULL, LOGGING_TIMESTAMP);
               Logging (NULL, LOGGING_SHUT);
            }
            PrevHour = HttpdTime7[3];
         }
      }
   }

   if (HttpdTicking)
   {
      if (reqidt != &Delta01Sec) sys$cantim (&Delta01Sec, 0);
      status = sys$setimr (0, &Delta01Sec, &HttpdTick, &Delta01Sec, 0);
   }
   else
   {
      if (reqidt != &Delta60Sec) sys$cantim (&Delta60Sec, 0);
      status = sys$setimr (0, &Delta60Sec, &HttpdTick, &Delta60Sec, 0);
   }
   if (VMSnok (status)) ErrorExitVmsStatus (status, "sys$setimr", FI_LI);
}

/*****************************************************************************/
/*
HttpdTickSecond is just a one second period, not a timestamp per se.
*/

ulong HttpdGetTickSecond ()

{
   static uint64  FirstTick64;

   uint64  time64;

   /*********/
   /* begin */
   /*********/

   if (!FirstTick64) sys$gettim (&FirstTick64);
   sys$gettim (&time64);
   return ((ulong)((time64 - FirstTick64) / 10000000));
}

/*****************************************************************************/
/*
Set the timer counters for the request according to the function code. 
HttpdSupervisor() will monitor these counters.  The period is set by adding the
period in seconds to the current second count to derive a value in the furture. 
When this is reached or exceeded the timer has expired.   The 'DurationSeconds'
is an optional parameter.  If set to zero the standard timer values are used. 
If -1 then the timer expires at the next supervision (i.e. immediately).  If
otherwise non-zero the value is used.  This allows CGI callouts and scripting
control to set these with specific values.
*/

HttpdTimerSet
(
REQUEST_STRUCT *rqptr,
int Function,
int DurationSeconds
)
{
   static BOOL  Initialize = true;
   static ulong  InputSeconds,
                 PersistentSeconds,
                 NoProgressPeriod,
                 OutputSeconds;

   int  idx, status,
        TimerSeconds;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdTimerSet() !UL !SL", Function, DurationSeconds);

   if (Initialize)
   {
      Initialize = false;
      if (Config.cfTimeout.Input)
         InputSeconds = Config.cfTimeout.Input;
      else
         InputSeconds = DEFAULT_TIMEOUT_INPUT_MINUTES * 60;
      if (Config.cfTimeout.Output)
         OutputSeconds = Config.cfTimeout.Output;
      else
         OutputSeconds = DEFAULT_TIMEOUT_OUTPUT_MINUTES * 60;
      if (Config.cfTimeout.NoProgress)
         NoProgressPeriod = Config.cfTimeout.NoProgress;
      else
         NoProgressPeriod = DEFAULT_TIMEOUT_NOPROGRESS_MINUTES * 60;
      if (Config.cfTimeout.Persistent)
         PersistentSeconds = Config.cfTimeout.Persistent;
      else
         PersistentSeconds = DEFAULT_TIMEOUT_PERSISTENT_SECONDS;
      /* ensure small periods are at least that duration */
      if (PersistentSeconds && PersistentSeconds < 10) PersistentSeconds++;
   }

   /* once the request has been terminated (and aborted) that's it! */
   if (rqptr->rqTmr.TimeoutCount) return;

   switch (Function)
   {
      case TIMER_INPUT :

          rqptr->rqTmr.PersistentSecond =
            rqptr->rqTmr.NoProgressBytesRx =
            rqptr->rqTmr.NoProgressBytesTx =
            rqptr->rqTmr.NoProgressSecond =
            rqptr->rqTmr.NoProgressPeriod =
            rqptr->rqTmr.OutputSecond =
            rqptr->rqTmr.TerminateSecond =
            rqptr->rqTmr.TimeoutType =
            rqptr->rqTmr.ThrottleSecond = 0;

         if (DurationSeconds)
            TimerSeconds = DurationSeconds;
         else
            TimerSeconds = InputSeconds;

         if (WATCHING (rqptr, WATCH_INTERNAL))
            WatchThis (WATCHITM(rqptr), WATCH_INTERNAL,
                       "TIMER input !SL seconds", TimerSeconds);

         rqptr->rqTmr.InputSecond = HttpdTickSecond + TimerSeconds + 1;

         break;

      case TIMER_OUTPUT :

         rqptr->rqTmr.InputSecond =
            rqptr->rqTmr.PersistentSecond =
            rqptr->rqTmr.TerminateSecond =
            rqptr->rqTmr.TimeoutType =
            rqptr->rqTmr.ThrottleSecond = 0;

         /* establish the baseline no-progress indicators (lsb) */
         rqptr->rqTmr.NoProgressBytesRx = rqptr->NetIoPtr->BytesRawRx64;
         rqptr->rqTmr.NoProgressBytesTx = rqptr->NetIoPtr->BytesRawTx64;

         if (DurationSeconds)
            TimerSeconds = DurationSeconds;
         else
         if (rqptr->rqPathSet.TimeoutOutput)
            TimerSeconds = rqptr->rqPathSet.TimeoutOutput;
         else
            TimerSeconds = OutputSeconds;

         if (rqptr->rqPathSet.TimeoutNoProgress)
            rqptr->rqTmr.NoProgressPeriod = rqptr->rqPathSet.TimeoutNoProgress;
         else
            rqptr->rqTmr.NoProgressPeriod = NoProgressPeriod;

         if (WATCHING (rqptr, WATCH_INTERNAL))
            WatchThis (WATCHITM(rqptr), WATCH_INTERNAL,
                       "TIMER output !SL/!UL seconds",
                       TimerSeconds, rqptr->rqTmr.NoProgressPeriod);

         rqptr->rqTmr.NoProgressSecond =
            HttpdTickSecond + rqptr->rqTmr.NoProgressPeriod + 1;

         rqptr->rqTmr.OutputSecond = HttpdTickSecond + TimerSeconds + 1;

         /* use the smaller of the two values to establish the list */
         if (rqptr->rqTmr.NoProgressPeriod < TimerSeconds)
            TimerSeconds = rqptr->rqTmr.NoProgressPeriod;

         break;

      case TIMER_NOPROGRESS :

         rqptr->rqTmr.InputSecond =
            rqptr->rqTmr.PersistentSecond =
            rqptr->rqTmr.TerminateSecond =
            rqptr->rqTmr.TimeoutType =
            rqptr->rqTmr.ThrottleSecond = 0;

         /* establish the baseline no-progress indicators (lsb) */
         rqptr->rqTmr.NoProgressBytesRx = rqptr->NetIoPtr->BytesRawRx64;
         rqptr->rqTmr.NoProgressBytesTx = rqptr->NetIoPtr->BytesRawTx64;

         if (DurationSeconds)
            rqptr->rqTmr.NoProgressPeriod = DurationSeconds;
         else
         if (rqptr->rqPathSet.TimeoutNoProgress)
            rqptr->rqTmr.NoProgressPeriod = rqptr->rqPathSet.TimeoutNoProgress;
         else
            rqptr->rqTmr.NoProgressPeriod = NoProgressPeriod;

         if (WATCHING (rqptr, WATCH_INTERNAL))
            WatchThis (WATCHITM(rqptr), WATCH_INTERNAL,
                       "TIMER no-progress !UL seconds",
                       rqptr->rqTmr.NoProgressPeriod);

         rqptr->rqTmr.NoProgressSecond =
            HttpdTickSecond + rqptr->rqTmr.NoProgressPeriod + 1;

         /* no need to adjust the list! */
         return;

      case TIMER_PERSISTENT :

         rqptr->rqTmr.InputSecond =
            rqptr->rqTmr.OutputSecond =
            rqptr->rqTmr.NoProgressBytesRx =
            rqptr->rqTmr.NoProgressBytesTx =
            rqptr->rqTmr.NoProgressSecond =
            rqptr->rqTmr.NoProgressPeriod =
            rqptr->rqTmr.TerminateSecond =
            rqptr->rqTmr.TimeoutType =
            rqptr->rqTmr.ThrottleSecond = 0;

         if (DurationSeconds)
            TimerSeconds = DurationSeconds;
         else
            TimerSeconds = PersistentSeconds;

         if (WATCHING (rqptr, WATCH_INTERNAL))
            WatchThis (WATCHITM(rqptr), WATCH_INTERNAL,
                       "TIMER persistent !SL seconds", TimerSeconds);

         rqptr->rqTmr.PersistentSecond = HttpdTickSecond + TimerSeconds + 1;

         break;

      case TIMER_THROTTLE :

         rqptr->rqTmr.InputSecond =
            rqptr->rqTmr.PersistentSecond =
            rqptr->rqTmr.NoProgressBytesRx =
            rqptr->rqTmr.NoProgressBytesTx =
            rqptr->rqTmr.NoProgressSecond =
            rqptr->rqTmr.NoProgressPeriod =
            rqptr->rqTmr.OutputSecond =
            rqptr->rqTmr.TerminateSecond =
            rqptr->rqTmr.TimeoutType = 0;

         if (DurationSeconds)
            TimerSeconds = DurationSeconds;
         else
         /* timeout-busy only becomes affective after any timeout-queue */
         if (rqptr->rqPathSet.ThrottleTimeoutQueue)
            TimerSeconds = rqptr->rqPathSet.ThrottleTimeoutQueue;
         else
         if (rqptr->rqPathSet.ThrottleTimeoutBusy)
            TimerSeconds = rqptr->rqPathSet.ThrottleTimeoutBusy;
         else
            TimerSeconds = OutputSeconds;

         if (WATCHING (rqptr, WATCH_INTERNAL))
            WatchThis (WATCHITM(rqptr), WATCH_INTERNAL,
                       "TIMER throttle !SL seconds", TimerSeconds);

         rqptr->rqTmr.ThrottleSecond = HttpdTickSecond + TimerSeconds + 1;

         break;

      case TIMER_TERMINATE :

         rqptr->rqTmr.InputSecond =
            rqptr->rqTmr.PersistentSecond =
            rqptr->rqTmr.NoProgressBytesRx =
            rqptr->rqTmr.NoProgressBytesTx =
            rqptr->rqTmr.NoProgressSecond =
            rqptr->rqTmr.NoProgressPeriod =
            rqptr->rqTmr.OutputSecond =
            rqptr->rqTmr.ThrottleSecond =
            rqptr->rqTmr.TimeoutType = 0;

         if (WATCHING (rqptr, WATCH_INTERNAL))
            WatchThis (WATCHITM(rqptr), WATCH_INTERNAL, "TIMER terminate");

         if (DurationSeconds)
            TimerSeconds = DurationSeconds;
         else
            TimerSeconds = 0;

         rqptr->rqTmr.TerminateSecond = HttpdTickSecond + TimerSeconds + 1;

         break;

      default :
         ErrorExitVmsStatus (SS$_BUGCHECK, ErrorSanityCheck, FI_LI);
   }

   /* add/move to new list */
   HttpdSupervisorList (rqptr, TimerSeconds);

   rqptr->rqTmr.TimeoutCount = 0;
}

/*****************************************************************************/
/*
Whenever at least one request is being processed this function is called every
second by HttpdTick() to supervise the requests' progress.  An array of lists
is maintained so that the duration of the scan is somewhat limited each second,
peaks occuring only when non-one-second lists need scanning.  Timer duration
counts are set by adding the timer period in seconds to the current second
count to get a second count in the future.  When this is reached  or exceeded
the timer has expired.  Time queue entries are moved from list to list as the
remaining period in seconds changes, ensuring that the entry is checked at
appropriate intervals.  Return true to indicate the HTTPd should continue to
tick.
*/

BOOL HttpdSupervisor ()

{
   int  idx, retval,
        ChunkSeconds,
        DeltaSecondCount,
        TimerSecond,
        TimeoutType;
   uint  cat;
   HTTP2_STRUCT  *h2ptr;
   LIST_ENTRY  *leptr;
   NETIO_STRUCT  *ioptr;
   PROXY_TASK  *ptkptr;
   REQUEST_STRUCT  *rqeptr;

   /*********/
   /* begin */
   /*********/

/**
   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
   {
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "SUPERVISOR !UL", HttpdTickSecond);
      WatchDataFormatted ("SECONDS COUNT SCAN\n");
      for (idx = 1; idx <= SUPERVISOR_LIST_MAX; idx++)
      {
         ChunkSeconds = SupervisorListArray[idx].ChunkSeconds;
         WatchDataFormatted ("!7UL !5UL !AZ\n",
            SupervisorListArray[idx].ChunkSeconds,
            LIST_GET_COUNT (&SupervisorListArray[idx].RequestList),
            (idx == 1 || !(HttpdTickSecond % ChunkSeconds)) ? " YES" : "  no");
      }
   }
**/

   if (RequestList.HeadPtr == NULL) return (false);

   /************************************/
   /* update selected network counters */
   /************************************/

   if (!(HttpdTickSecond % SUPERVISOR_NETWORK_UPDATE))
   {
      InstanceMutexLock (INSTANCE_MUTEX_HTTPD);
      if (ActivityTotalMinutes) InstanceMutexLock (INSTANCE_MUTEX_ACTIVITY);

      for (leptr = RequestList.HeadPtr; leptr; leptr = leptr->NextPtr)
      {
         rqeptr = (REQUEST_STRUCT*)leptr;
         ioptr = rqeptr->NetIoPtr;
         if (!ioptr->Channel)
            if (rqeptr->Http2Stream.Http2Ptr)
               ioptr = rqeptr->Http2Stream.Http2Ptr->NetIoPtr;

         if (!(ioptr->BytesTallyRx64 || ioptr->BytesTallyTx64)) continue;

         /* update activity first, it uses the bytes accounted-for value */
         if (ActivityTotalMinutes) GraphActivityUpdate (rqeptr, false);

         /* update using the running tally accumulators */
         AccountingPtr->BytesRawRx64[HTTP12] += ioptr->BytesTallyRx64;
         AccountingPtr->BytesRawTx64[HTTP12] += ioptr->BytesTallyTx64;
         AccountingPtr->BlocksRawTx64[HTTP12] += ioptr->BlocksTallyTx64;
         AccountingPtr->BlocksRawRx64[HTTP12] += ioptr->BlocksTallyRx64;

         /* reset the running tally accumulators */
         ioptr->BytesTallyRx64 = ioptr->BytesTallyTx64 =
            ioptr->BlocksTallyRx64 = ioptr->BlocksTallyTx64 = 0;

         if (ptkptr = (PROXY_TASK*)rqeptr->ProxyTaskPtr)
         {
            if (!(ioptr = ptkptr->NetIoPtr)) continue;

            if (!(ioptr->BytesTallyRx64 || ioptr->BytesTallyTx64)) continue;

            /* update proxy using the running tally accumulators */
            ProxyAccountingPtr->BytesRawRx64 += ioptr->BytesTallyRx64;
            ProxyAccountingPtr->BytesRawTx64 += ioptr->BytesTallyTx64;
            ProxyAccountingPtr->BlocksRawTx64 += ioptr->BlocksTallyTx64;
            ProxyAccountingPtr->BlocksRawRx64 += ioptr->BlocksTallyRx64;

            /* reset the running tally accumulators */
            ioptr->BytesTallyRx64 = ioptr->BytesTallyTx64 =
               ioptr->BlocksTallyRx64 = ioptr->BlocksTallyTx64 = 0;
         }
      }

      if (ActivityTotalMinutes) InstanceMutexUnLock (INSTANCE_MUTEX_ACTIVITY);
      InstanceMutexUnLock (INSTANCE_MUTEX_HTTPD);
   }

   /***************************/
   /* scan supervisor list(s) */
   /***************************/

   for (idx = 1; idx <= SUPERVISOR_LIST_MAX; idx++)
   {
      ChunkSeconds = SupervisorListArray[idx].ChunkSeconds;
      if (!(idx == 1 || !(HttpdTickSecond % ChunkSeconds))) continue;
      DeltaSecondCount = HttpdTickSecond + ChunkSeconds;

      /* process the current request list entries */
      leptr = SupervisorListArray[idx].RequestList.HeadPtr;
      while (leptr)
      {
         rqeptr = (REQUEST_STRUCT*)leptr->DataPtr;
         leptr = leptr->NextPtr;
/**
         if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
            WatchThis (WATCHALL, WATCH_MOD__OTHER,
"!UL <- !UL -> !UL (!UL) in: !UL o:!UL np:!UL ka:!UL term:!UL",
               leptr->PrevPtr, leptr, leptr->NextPtr, rqeptr,
               rqeptr->rqTmr.InputSecond, rqeptr->rqTmr.OutputSecond,
               rqeptr->rqTmr.NoProgressSecond, rqeptr->rqTmr.PersistentSecond,
               rqeptr->rqTmr.TimeoutCount);
**/
         if (rqeptr->rqTmr.TimeoutCount)
         {
            rqeptr->rqTmr.TimeoutCount++;
            if (rqeptr->rqTmr.TimeoutCount == TIMEOUT_ABORT_SECONDS)
               NetAbortSocket (rqeptr);
            continue;
         }

         /* ordered in the most common occurance of timings */
         if (rqeptr->rqTmr.OutputSecond)
         {
            /*********************/
            /* output/noprogress */
            /*********************/

            if (rqeptr->rqTmr.NoProgressBytesTx !=
                rqeptr->NetIoPtr->BytesRawTx64 ||
                rqeptr->rqTmr.NoProgressBytesRx !=
                rqeptr->NetIoPtr->BytesRawRx64)
            {
               rqeptr->rqTmr.NoProgressSecond =
                  HttpdTickSecond + rqeptr->rqTmr.NoProgressPeriod + 1;
               rqeptr->rqTmr.NoProgressBytesRx = rqeptr->NetIoPtr->BytesRawRx64;
               rqeptr->rqTmr.NoProgressBytesTx = rqeptr->NetIoPtr->BytesRawTx64;
            }

            /* use the lesser of output and no-progress counts */
            if (rqeptr->rqTmr.OutputSecond <= rqeptr->rqTmr.NoProgressSecond)
            {
               if (rqeptr->rqTmr.OutputSecond > DeltaSecondCount) continue;
               TimerSecond = rqeptr->rqTmr.OutputSecond;
               TimeoutType = TIMEOUT_OUTPUT;
            }
            else
            {
               if (rqeptr->rqTmr.NoProgressSecond > DeltaSecondCount) continue;
               TimerSecond = rqeptr->rqTmr.NoProgressSecond;
               TimeoutType = TIMEOUT_NOPROGRESS;
            }

            if (TimerSecond > HttpdTickSecond)
            {
               /* move to new list */
               HttpdSupervisorList (rqeptr, TimerSecond-HttpdTickSecond);
               continue;
            }

            rqeptr->rqTmr.TimeoutType = TimeoutType;
            /* fall through to shut down */
         }
         else
         if (TimerSecond = rqeptr->rqTmr.InputSecond)
         {
            /*********/
            /* input */
            /*********/

            if (TimerSecond > DeltaSecondCount) continue;
            if (TimerSecond > HttpdTickSecond)
            {
               /* move to new list */
               HttpdSupervisorList (rqeptr, TimerSecond-HttpdTickSecond);
               continue;
            }
            rqeptr->rqTmr.TimeoutType = TIMEOUT_INPUT;
            /* fall through to shut down */
         }
         else
         if (TimerSecond = rqeptr->rqTmr.PersistentSecond)
         {
            /*************************/
            /* persistent connection */
            /*************************/

            if (TimerSecond > DeltaSecondCount) continue;
            if (TimerSecond > HttpdTickSecond)
            {
               /* move to new list */
               HttpdSupervisorList (rqeptr, TimerSecond-HttpdTickSecond);
               continue;
            }
            rqeptr->rqTmr.TimeoutType = TIMEOUT_PERSISTENT;
            /* fall through to shut down */
         }
         else
         if (TimerSecond = rqeptr->rqTmr.ThrottleSecond)
         {
            /************/
            /* throttle */
            /************/

            if (TimerSecond > DeltaSecondCount) continue;
            if (TimerSecond > HttpdTickSecond)
            {
               /* move to new list */
               HttpdSupervisorList (rqeptr, TimerSecond-HttpdTickSecond);
               continue;
            }

            if (WATCHING (rqeptr, WATCH_INTERNAL))
               WatchThis (WATCHITM(rqeptr), WATCH_INTERNAL,
                          "TIMER throttle EXPIRED");

            /* does not fall through to shut down! */
            continue;
         }
         else
         if (TimerSecond = rqeptr->rqTmr.TerminateSecond)
         {
            /*************/
            /* terminate */
            /*************/

            if (TimerSecond > DeltaSecondCount) continue;
            if (TimerSecond > HttpdTickSecond)
            {
               /* move to new list */
               HttpdSupervisorList (rqeptr, TimerSecond-HttpdTickSecond);
               continue;
            }

            rqeptr->rqTmr.TimeoutType = TIMEOUT_TERMINATE;
            /* fall through to shut down */
         }

         /*************************/
         /* shut down the request */
         /*************************/

         if ((WATCH_ITM(rqeptr) &&
             WATCH_CATEGORY((cat = WATCH_CONNECT)) ||
             WATCH_CATEGORY((cat = WATCH_INTERNAL))))
             WatchThis (WATCHITM(rqeptr), cat, "TIMER !AZ",
                        HttpdTimeoutType (rqeptr->rqTmr.TimeoutType));

         if (Watch.RequestPtr == rqeptr)
         {
            WatchEnd ();
            continue;
         }

         rqeptr->rqTmr.TimeoutCount++;

         if (rqeptr->rqTmr.TimeoutType == TIMEOUT_INPUT)
            rqeptr->rqResponse.HttpStatus = 408;
         else
         if (Watch.RequestPtr != rqeptr)
            rqeptr->rqResponse.HttpStatus = 500;

         RequestAbort (rqeptr);
      }
   }

   return (true);
}

/*****************************************************************************/
/*
Return a pointer to a string.
*/

char* HttpdTimeoutType (int type)

{
   /*********/
   /* begin */
   /*********/

   switch (type)
   {
      case TIMEOUT_NONE : return ("");
      case TIMEOUT_INPUT : return ("(t/o:input) ");
      case TIMEOUT_THROTTLE : return ("(t/o:throttle) ");
      case TIMEOUT_OUTPUT : return ("(t/o:output) ");
      case TIMEOUT_NOPROGRESS : return ("(t/o:noprogress) ");
      case TIMEOUT_PERSISTENT : return ("(t/o:persistent) ");
      case TIMEOUT_TERMINATE : return ("(t/o:terminate) ");
      default : return ("(t/o:unknown)");
   }
}

/*****************************************************************************/
/*
If necessary remove a request entry from it's appropriate supervisor array
list.  The search for an element within the range of timer currently still
outstanding with the request and add it to the HEAD of that list.  The head is
important because HttpdSupervisor() scans through these lists from head to tail
and if the tail is played with at the same time all hell breaks loose.
*/

HttpdSupervisorList
(
REQUEST_STRUCT *rqptr,
int TimerSeconds
)
{
   int  idx;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "HttpdSupervisorList() !SL", TimerSeconds);

   if (rqptr->rqTmr.ListIndex)
   {
      /* remove from current list */
      ListRemove (&SupervisorListArray[rqptr->rqTmr.ListIndex].RequestList,
                  &rqptr->rqTmr.ListEntry);
      rqptr->rqTmr.ListIndex = 0;
      rqptr->rqTmr.ListEntry.DataPtr = NULL;
   }

   /* just removing from timer list */
   if (TimerSeconds == -1) return;

   /* add to new list */
   for (idx = 1; idx < SUPERVISOR_LIST_MAX; idx++)
   {
      if (TimerSeconds > SupervisorListArray[idx+1].ChunkSeconds)
         continue;
      /* add this to the head of the list (less carpet pulling that way) */
      ListAddHead (&SupervisorListArray[idx].RequestList,
                   &rqptr->rqTmr.ListEntry, LIST_ENTRY_TYPE_TIMER);
      rqptr->rqTmr.ListEntry.DataPtr = (void*)rqptr;
      rqptr->rqTmr.ListIndex = idx;
      return;
   }

   ErrorNoticed (rqptr, 0, "supervisor list", FI_LI);

   /* ensure it goes somewhere */
   ListAddHead (&SupervisorListArray[1].RequestList,
                &rqptr->rqTmr.ListEntry, LIST_ENTRY_TYPE_TIMER);
   rqptr->rqTmr.ListEntry.DataPtr = (void*)rqptr;
   rqptr->rqTmr.ListIndex = 1;
}

/*****************************************************************************/
/*
Provide a report on the server supervisor (do tell!)
*/ 

HttpdSupervisorReport (REQUEST_STRUCT *rqptr)

{
   static char  BeginPage [] =
"<p><table class=\"ctgry\">\n\
<tr><td>\n\
<table class=\"lftlft\">\n\
<tr>\
<th class=\"sbttl\">List</th>\
<th class=\"sbttl talft\">Seconds</th>\
<th class=\"sbttl\">Count</th>\
<th class=\"sbttl\">Scan</th>\
</tr>\n\
<tr HEIGHT=5></tr>\n";

   static char  ListFao [] =
"<tr>\
<th>!UL</th>\
<td>!&@</td>\
<td class=\"targht\">!UL</td>\
<td>!AZ</td>\
</tr>\n";

   static char  EndOfPageFao [] =
"<tr>\
<th class=\"sbttl targht\" colspan=\"2\">Total:</th>\
<td>!UL</td>\
</tr>\n\
</table>\n\
<p><table class=\"rghtlft\">\n\
<tr><th>Supervisor:</th>\
<td>!UL</td></tr>\
<tr><th>Year:</th>\
<td>!UL</td></tr>\
<tr><th>Month:</th>\
<td>!UL</td></tr>\
<tr><th>Day:</th>\
<td>!UL</td></tr>\
<tr><th>Hour:</th>\
<td>!UL</td></tr>\
<tr><th>Minute:</th>\
<td>!UL</td></tr>\
<tr><th>Second:</th>\
<td>!UL</td></tr>\
</table>\n\
</td></tr>\n\
</table>\n\
</div>\n\
</body>\n\
</html>\n";

   int  idx, status,
        ChunkRange,
        ChunkSeconds,
        Count,
        CountTotal;
   ulong  *vecptr;
   ulong  FaoVector [32];

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdSupervisorReport()");

   AdminPageTitle (rqptr, "Supervisor Report", BeginPage);

   ChunkRange = CountTotal = 0;
   for (idx = 1; idx < SUPERVISOR_LIST_MAX; idx++)
   {
      ChunkSeconds = SupervisorListArray[idx].ChunkSeconds;
      ChunkRange = SupervisorListArray[idx+1].ChunkSeconds;
      Count = LIST_GET_COUNT (&SupervisorListArray[idx].RequestList);
      CountTotal += Count;

      vecptr = FaoVector;
      *vecptr++ = idx;
      if (idx == 9)
      {
         *vecptr++ = "!UL - <i>infinite</i>";
         *vecptr++ = ChunkSeconds;
      }
      else
      {
         *vecptr++ = "!UL - !UL";
         *vecptr++ = ChunkSeconds;
         *vecptr++ = ChunkRange-1;
      }
      *vecptr++ = Count;
      if (idx == 1 || (HttpdTickSecond && !(HttpdTickSecond % ChunkSeconds)))
         *vecptr++ = "YES";
      else
         *vecptr++ = "no";

      status = FaolToNet (rqptr, ListFao, &FaoVector);
      if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);
   }

   vecptr = FaoVector;
   *vecptr++ = CountTotal;
   *vecptr++ = HttpdTickSecond;
   *vecptr++ = HttpdTime7[0];
   *vecptr++ = HttpdTime7[1];
   *vecptr++ = HttpdTime7[2];
   *vecptr++ = HttpdTime7[3];
   *vecptr++ = HttpdTime7[4];
   *vecptr++ = HttpdTime7[5];

   status = FaolToNet (rqptr, EndOfPageFao, &FaoVector);
   if (VMSnok (status)) ErrorNoticed (rqptr, status, NULL, FI_LI);

   rqptr->rqResponse.PreExpired = PRE_EXPIRE_ADMIN;
   ResponseHeader200 (rqptr, "text/html", &rqptr->NetWriteBufferDsc);

   AdminEnd (rqptr);
}

/*****************************************************************************/
/*
Create and/or map (an existing) a permanent global section.  This global
section is used to contain the accounting structure and other data that might
be of interest to a separate utility such a HTTPDMON.  The utility merely maps
the section and continues to read values from the "common" memory.  This used
to be stored in logical names but this is seen as a more elegant and efficient
method.  The section name is based on the string "WASD_HTTPD_" plus the
"official" port number of the server process.  As this is a permanent global
section it can "permanently" store accounting data between server invocations
(in much the same way the old method of using logicals could).  Because it is
permanent though, and global section is created on a per-server basis, anyone
who "plays around" with servers on a whole range of "official" port numbers run
the risk of consuming all system sections and/or global pages.  To allow for
removing no-longer-required global sections this function contains a hack
allowing the server qualifier /GBLSEC=DELETE (plus /INSTANCE= if necessary) to
delete the corresponding global section.
*/ 

int HttpdGblSecInit ()

{
   static char  ReportGblSecPages [] =
"%HTTPD-I-GBLSEC, !AZ global section of !UL page(let)s\n";

   /* global, allocate space, system, in page file, permanent, writable */
   static int CreFlags = SEC$M_GBL | SEC$M_EXPREG | SEC$M_SYSGBL |
                         SEC$M_PAGFIL | SEC$M_PERM | SEC$M_WRT;
   static int DelFlags = SEC$M_SYSGBL;
   /* system & owner full access, group and world no access */
   static ulong  ProtectionMask = 0xff00;
   /* it is recommended to map into any virtual address in the region (P0) */
   static ulong  InAddr [2] = { 0x200, 0x200 };

   int  attempt, status,
        GblSecPages,
        PageCount;
   short  ShortLength;
   ulong  RetAddr [2];
   char  GblSecName [32];
   $DESCRIPTOR (GblSecNameDsc, GblSecName);
   HTTPD_GBLSEC  *gsptr;

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdGblSecInit()");

   FaoToBuffer (GblSecName, sizeof(GblSecName), &ShortLength,
                GBLSEC_NAME_FAO, HTTPD_NAME, HTTPD_GBLSEC_VERSION_NUMBER,
                InstanceEnvNumber, "HTTPD");
   GblSecNameDsc.dsc$w_length = ShortLength;

   if (CliGblSecDelete)
   {
      /* delete the specified global section */
      sys$setprv (1, &GblSecPrvMask, 0, 0);
      status = sys$dgblsc (DelFlags, &GblSecNameDsc, 0);
      sys$setprv (0, &GblSecPrvMask, 0, 0);
      return (status);
   }

   GblSecPages = sizeof(HTTPD_GBLSEC) / 512;
   if (GblSecPages & 0x1ff) GblSecPages++;

   /* do not create a permanent global section */
   if (CliGblSecNoPerm) CreFlags &= ~SEC$M_PERM;

   for (attempt = 1; attempt <= 2; attempt++)
   {
      /* create and/or map the specified global section */
      sys$setprv (1, &GblSecPrvMask, 0, 0);
      status = sys$crmpsc (&InAddr, &RetAddr, 0, CreFlags,
                           &GblSecNameDsc, 0, 0, 0, GblSecPages, 0,
                           ProtectionMask, GblSecPages);
      sys$setprv (0, &GblSecPrvMask, 0, 0);

      if (WATCH_MODULE(WATCH_MOD__OTHER))
         WatchThis (WATCHALL, WATCH_MOD__OTHER,
                    "sys$crmpsc() !&S begin:!UL end:!UL bytes:!UL",
                    status, RetAddr[0], RetAddr[1], RetAddr[1] - RetAddr[0]);

      PageCount = (RetAddr[1]+1) - RetAddr[0] >> 9;
      HttpdGblSecPtr = gsptr = (HTTPD_GBLSEC*)RetAddr[0];
      if (VMSnok (status) || status == SS$_CREATED) break;

      /* section already exists, break if 'same size' and version! */
      if (PageCount >= GblSecPages &&
          HttpdGblSecPtr->GblSecVersion == HttpdGblSecVersion)
         break;

      /* delete the current global section, have one more attempt */
      sys$setprv (1, &GblSecPrvMask, 0, 0);
      status = sys$dgblsc (DelFlags, &GblSecNameDsc, 0);
      sys$setprv (0, &GblSecPrvMask, 0, 0);
      status = SS$_IDMISMATCH;
   }

   if (VMSnok (status))
   {
      /* must have this global section! */
      char  String [256];
      FaoToBuffer (String, sizeof(String), NULL,
                   "1 global section, !UL global pages", GblSecPages);
      ErrorExitVmsStatus (status, String, FI_LI);
   }

   if (status == SS$_CREATED)
      FaoToStdout (ReportGblSecPages, "created", PageCount);
   else
      FaoToStdout (ReportGblSecPages, "existing", PageCount);

   /* if it has a different structure reset the storage */
   if (gsptr->GblSecLength != sizeof(HTTPD_GBLSEC))
   {
      memset (gsptr, 0, sizeof(HTTPD_GBLSEC));
      ControlZeroAccounting ();
   }

   /* if it was just created or reset due to different structure */
   if (!gsptr->GblSecVersion)
   {
      gsptr->GblSecVersion = HttpdGblSecVersion;
      gsptr->GblSecLength = sizeof(HTTPD_GBLSEC);
   }

   HttpdGblSecPages = PageCount;
   AccountingPtr = &gsptr->Accounting;
   ProxyAccountingPtr = &gsptr->ProxyAccounting;
   gsptr->HttpdProcessId = HttpdProcess.Pid;
   strzcpy (gsptr->HttpdVersion, HttpdVersion, sizeof(gsptr->HttpdVersion));

   if (CliGblSecNoPerm)
   {
      GblSectionCount++;
      GblPageCount += PageCount;
   }
   else
   {
      GblSectionPermCount++;
      GblPagePermCount += PageCount;
   }

   return (status);
}

/*****************************************************************************/
/*
The above funtion *creates* and maps.  This just maps.
*/

int HttpdGblSecMap ()

{
   /* system global section, map into first available virtual address */
   static int MapFlags = SEC$M_WRT | SEC$M_SYSGBL | SEC$M_EXPREG;
   /* it is recommended to map into any virtual address in the region (P0) */
   static unsigned long  InAddr [2] = { 0x200, 0x200 };

   static char  HttpdGblSecName [32];
   static $DESCRIPTOR (HttpdGblSecNameDsc, HttpdGblSecName);
   static $DESCRIPTOR (HttpdGblSecNameFaoDsc, GBLSEC_NAME_FAO);

   int  status,
        ByteSize,
        PageSize;
   unsigned short  ShortLength;
   unsigned long  RetAddr [2];

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER, "HttpdGblSecMap()");

   AccountingPtr = HttpdGblSecPtr = NULL;

   sys$fao (&HttpdGblSecNameFaoDsc, &ShortLength, &HttpdGblSecNameDsc,
            HTTPD_NAME, HTTPD_GBLSEC_VERSION_NUMBER,
            InstanceEnvNumber, "HTTPD");
   HttpdGblSecNameDsc.dsc$w_length = ShortLength;

   status = sys$mgblsc (&InAddr, &RetAddr, 0, MapFlags, &HttpdGblSecNameDsc,
                        0, 0);

   if (WATCH_MODULE(WATCH_MOD__OTHER) && WATCH_MODULE(WATCH_MOD__DETAIL))
      WatchThis (WATCHALL, WATCH_MOD__OTHER,
                 "sys$mgblsc() !AZ %X!8XL begin:!UL end:!UL bytes:!UL",
                 HttpdGblSecName, status, RetAddr[0], RetAddr[1],
                 RetAddr[1] - RetAddr[0]);

   if (VMSnok (status)) return (status);

   ByteSize = (RetAddr[1]+1) - RetAddr[0];
   PageSize = (RetAddr[1]+1) - RetAddr[0] >> 9;
   HttpdGblSecPtr = (HTTPD_GBLSEC*)RetAddr[0];

   if (HttpdGblSecPtr->GblSecVersion != HTTPD_GBLSEC_VERSION_NUMBER ||
       HttpdGblSecPtr->GblSecLength != sizeof(HTTPD_GBLSEC))
      return (SS$_GBLSEC_MISMATCH);

   AccountingPtr = &HttpdGblSecPtr->Accounting;

   return (SS$_NORMAL);
}

/*****************************************************************************/
/*
Populate |HttpdProcess.ImageInfo| with a string that identifies the actual
image in use.  This can then be used in log entries, process output, etc.

IA64 ELF image analysis plagiarised from:
//  File: elf_imginfo.c
//  Author: Hartmut Becker
//  Creation Date:  24-Sep-2004
*/ 

void HttpdImageInfo ()

{
   static int  ImagNameLength;
   static char ImagName [256];
   static VMS_ITEM_LIST3
   JpiItems [] =
   {
     { sizeof(ImagName), JPI$_IMAGNAME, &ImagName, &ImagNameLength },
     { 0,0,0,0 }
   };

#ifdef ELVEN
   static const char MagicPlus [] =
   {
       EHDR$K_ELFMAG0, EHDR$K_ELFMAG1, EHDR$K_ELFMAG2, EHDR$K_ELFMAG3,
       EHDR$K_ELFCLASS64, EHDR$K_ELFDATA2LSB
   };
#endif

   int  status;
   ushort  Length;
   char  *cptr,
         *ImageDatePtr,
         *ImageIdentPtr,
         *ImageNamePtr;
   char  ErrorInfo [256],
         ImageRecord [512];
   ulong  Genesis [2];
   FILE  *ImageFile;
   IO_SB  IOsb;

#ifdef ELVEN
   int  cnt;
   ulong  ImageDate [2];
   char  *secptr = NULL;
   ELF64_EHDR  ElfHeader;
   ELF64_SHDR  *shptr = NULL;
   ELF64_NHDR  *nhptr;
#endif

   /*********/
   /* begin */
   /*********/

   if (WATCH_MODULE(WATCH_MOD_NET))
      WatchThis (WATCHALL, WATCH_MOD_NET, "HttpdImageInfo()");

   memset (ErrorInfo, 0, sizeof(ErrorInfo));

   /* get the image name */
   status = sys$getjpiw (EfnWait, 0, 0, &JpiItems, &IOsb, 0, 0);
   if (VMSok (status)) status = IOsb.Status;
   if (VMSnok (status)) ErrorExitVmsStatus (status, NULL, FI_LI);

   HttpdProcess.ImageInfo[ImagNameLength] = '\0';

   /* HttpdProcessInfo() uses this to obtain image name then space is reused */
   ImageFile = fopen (ImagName, "r", "shr=get", "dna=WASD_EXE:.EXE");
   if (!ImageFile)
   {
      FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                   "%X!8XL(!UL)", vaxc$errno, __LINE__);
      goto ImageIdentFailed;
   }

#ifndef ELVEN
   if (fread (&ImageRecord, sizeof(ImageRecord), 1, ImageFile) != 1)
   {
      FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                   "%X!8XL(!UL)", vaxc$errno, __LINE__);
      goto ImageIdentFailed;
   }
#endif

#ifdef __ALPHA
   ImageNamePtr = ImageRecord + 200;
   ImageIdentPtr = ImageRecord + 240;
   ImageDatePtr = ImageRecord + 192;
#endif

#ifdef ELVEN

   ImageNamePtr = ImageIdentPtr = "?";
   ImageDatePtr = 0;

   if (fread (&ElfHeader, sizeof(ElfHeader), 1, ImageFile) != 1)
   {
      FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                   "%X!8XL(!UL)", vaxc$errno, __LINE__);
      goto ImageIdentFailed;
   }

   if (strncmp ((char*)&ElfHeader.ehdr$t_e_ident,
                MagicPlus,
                sizeof(MagicPlus)-1)) 
   {
      FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                   "ELF file format? (!UL)", __LINE__);
      goto ImageIdentFailed;
   }

   shptr = (ELF64_SHDR*) malloc (sizeof *shptr *ElfHeader.ehdr$w_e_shnum);
   if (fseek (ImageFile, ElfHeader.ehdr$q_e_shoff, SEEK_SET))
   {
      FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                   "%X!8XL(!UL)", vaxc$errno, __LINE__);
      goto ImageIdentFailed;
   }
   if (fread (shptr, sizeof *shptr*ElfHeader.ehdr$w_e_shnum, 1, ImageFile) != 1)
   {
      FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                   "%X!8XL(!UL)", vaxc$errno, __LINE__);
      goto ImageIdentFailed;
   }

   for (cnt = 1; cnt < ElfHeader.ehdr$w_e_shnum; cnt++)
   {
      if (shptr[cnt].shdr$l_sh_type == SHDR$K_SHT_NOTE)
      {
         secptr = malloc (shptr[cnt].shdr$q_sh_size);
         if (fseek (ImageFile, shptr[cnt].shdr$q_sh_offset, SEEK_SET))
         {
            FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                         "%X!8XL(!UL)", vaxc$errno, __LINE__);
            goto ImageIdentFailed;
         }
         if (fread (secptr, shptr[cnt].shdr$q_sh_size, 1, ImageFile) != 1)
         {
            FaoToBuffer (ErrorInfo+1, sizeof(ErrorInfo)-1, &Length,
                         "%X!8XL(!UL)", vaxc$errno, __LINE__);
            goto ImageIdentFailed;
         }

         for (nhptr = (ELF64_NHDR*)secptr;
              (char*)nhptr-secptr < shptr[cnt].shdr$q_sh_size;
              nhptr = (ELF64_NHDR*)((char*)nhptr+sizeof(ELF64_NHDR)+
                                ((nhptr->nhdr$q_nh_namesz+7)&~7)+
                                ((nhptr->nhdr$q_nh_descsz+7)&~7)))
         {
            if (nhptr->nhdr$q_nh_descsz > 0)
            {
               switch (nhptr->nhdr$q_nh_type)
               {
                  case NHDR$K_NT_VMS_LINKTIME:
                       ImageDatePtr = (ULONGPTR)
                                      ((char*)nhptr+sizeof(ELF64_NHDR) +
                                       ((nhptr->nhdr$q_nh_namesz+7)&~7));
                       memcpy (ImageDate, ImageDatePtr, 8);
                       ImageDatePtr = ImageDate;
                       break ;
                  case NHDR$K_NT_VMS_IMGNAM:
                       cptr = (char*)nhptr+sizeof(ELF64_NHDR) +
                              ((nhptr->nhdr$q_nh_namesz+7)&~7);
                       ImageNamePtr = malloc (strlen(cptr)+1);
                       strcpy (ImageNamePtr, cptr);
                       break ;
                  case NHDR$K_NT_VMS_IMGID:
                       cptr = (char*)nhptr+sizeof(ELF64_NHDR) +
                              ((nhptr->nhdr$q_nh_namesz+7)&~7);
                       ImageIdentPtr = malloc (strlen(cptr)+1);
                       strcpy (ImageIdentPtr, cptr);
                       break ;
                  case NHDR$K_NT_VMS_GSTNAM:
                       break ;
                  case NHDR$K_NT_VMS_IMGBID:
                       break ;
                  case NHDR$K_NT_VMS_LINKID:
                       break ;
                  default:
                       break ;
               }
            }
         }
         free (secptr);
      }
   }

   free (shptr);

#endif

   /* goto target */
   ImageIdentFailed:

   fclose (ImageFile);

   if (ErrorInfo[0])
   {
#ifdef ELVEN
      /* uses null-terminated strings */
      ImageNamePtr = ImageIdentPtr = ErrorInfo + 1;
#else
      /* uses counted strings */
      ImageNamePtr = ImageIdentPtr = ErrorInfo;
#endif
      memset (Genesis, 0, sizeof(Genesis));
      ImageDatePtr = Genesis;
   }

#ifdef ELVEN
   /* ever'thin's null-terminated in this brave new world? */
   FaoToBuffer (HttpdProcess.ImageInfo, sizeof(HttpdProcess.ImageInfo), NULL,
                "!AZ !AZ !%D !AZ",
                ImageNamePtr, ImageIdentPtr, ImageDatePtr, ImagName);
#else
   FaoToBuffer (HttpdProcess.ImageInfo, sizeof(HttpdProcess.ImageInfo), NULL,
                "!AC !AC !%D !AZ",
                ImageNamePtr, ImageIdentPtr, ImageDatePtr, ImagName);
#endif
}                                   

/*****************************************************************************/