1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
|
/*
* $LynxId: LYMain.c,v 1.210 2009/11/21 17:05:33 Bela.Lubkin Exp $
*/
#include <HTUtils.h>
#include <HTTP.h>
#include <HTParse.h>
#include <HTAccess.h>
#include <HTList.h>
#include <HTFile.h>
#include <UCMap.h>
#include <UCDefs.h>
#include <HTInit.h>
#include <HTAlert.h>
#include <LYCurses.h>
#include <LYStyle.h>
#include <HTML.h>
#include <LYUtils.h>
#include <LYGlobalDefs.h>
#include <LYOptions.h>
#include <LYSignal.h>
#include <LYGetFile.h>
#include <LYStrings.h>
#include <LYClean.h>
#include <LYCharSets.h>
#include <LYCharUtils.h>
#include <LYReadCFG.h>
#include <LYrcFile.h>
#include <LYKeymap.h>
#include <HTForms.h>
#include <LYList.h>
#include <LYJump.h>
#ifdef USE_SESSIONS
#include <LYSession.h>
#endif
#include <LYMainLoop.h>
#include <LYBookmark.h>
#include <LYCookie.h>
#include <LYPrettySrc.h>
#include <LYShowInfo.h>
#include <LYHistory.h>
#ifdef VMS
#include <HTFTP.h>
#endif /* !DECNET */
#ifdef __DJGPP__
#include <dos.h>
#include <dpmi.h>
#include <io.h>
#include <sys/stat.h>
#include <sys/exceptn.h>
#endif /* __DJGPP__ */
#ifdef __EMX__
#include <io.h>
#endif
#if defined(LOCALE) && (!defined(HAVE_LIBINTL_H) || !defined(LC_ALL))
#undef gettext /* Solaris locale.h prototypes gettext() */
#include <locale.h>
#ifndef HAVE_GETTEXT
#define gettext(s) s
#endif
#endif /* LOCALE */
#include <LYexit.h>
#include <LYLeaks.h>
/* ahhhhhhhhhh!! Global variables :-< */
#ifdef SOCKS
BOOLEAN socks_flag = TRUE;
#endif /* SOCKS */
#ifdef IGNORE_CTRL_C
BOOLEAN sigint = FALSE;
#endif /* IGNORE_CTRL_C */
#ifdef __DJGPP__
static char init_ctrl_break[1];
#endif /* __DJGPP__ */
#if USE_VMS_MAILER
char *mail_adrs = NULL; /* the mask for a VMS mail transport */
#endif
#ifdef VMS
/* create FIXED 512 binaries */
BOOLEAN UseFixedRecords = USE_FIXED_RECORDS;
#endif /* VMS */
#ifndef VMS
static char *lynx_version_putenv_command = NULL;
char *list_format = NULL; /* LONG_LIST formatting mask */
#endif /* !VMS */
char *ftp_format = NULL; /* LONG_LIST formatting mask */
#ifdef SYSLOG_REQUESTED_URLS
char *syslog_txt = NULL; /* syslog arb text for session */
BOOLEAN syslog_requested_urls = FALSE;
#endif
int cfg_bad_html = BAD_HTML_WARN;
#ifdef DIRED_SUPPORT
BOOLEAN lynx_edit_mode = FALSE;
BOOLEAN no_dired_support = FALSE;
HTList *tagged = NULL;
int LYAutoUncacheDirLists = 2; /* default dired uncaching behavior */
int dir_list_order = ORDER_BY_NAME;
int dir_list_style = MIXED_STYLE;
#ifdef OK_OVERRIDE
BOOLEAN prev_lynx_edit_mode = FALSE;
#endif /* OK_OVERRIDE */
#ifdef OK_PERMIT
#ifdef NO_CHANGE_EXECUTE_PERMS
BOOLEAN no_change_exec_perms = TRUE;
#else
BOOLEAN no_change_exec_perms = FALSE;
#endif /* NO_CHANGE_EXECUTE_PERMS */
#endif /* OK_PERMIT */
#endif /* DIRED_SUPPORT */
/* Number of docs cached in memory */
int HTCacheSize = DEFAULT_CACHE_SIZE;
#if defined(VMS) && defined(VAXC) && !defined(__DECC)
/* Don't dump doc cache unless this size is exceeded */
int HTVirtualMemorySize = DEFAULT_VIRTUAL_MEMORY_SIZE;
#endif /* VMS && VAXC && !_DECC */
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
#ifndef NEVER_ALLOW_REMOTE_EXEC
BOOLEAN local_exec = LOCAL_EXECUTION_LINKS_ALWAYS_ON;
#else
BOOLEAN local_exec = FALSE;
#endif /* NEVER_ALLOW_REMOTE_EXEC */
BOOLEAN local_exec_on_local_files =
LOCAL_EXECUTION_LINKS_ON_BUT_NOT_REMOTE;
#endif /* EXEC_LINKS || EXEC_SCRIPTS */
#if defined(LYNXCGI_LINKS) && !defined(VMS) /* WebSter Mods -jkt */
char *LYCgiDocumentRoot = NULL; /* DOCUMENT_ROOT in the lynxcgi env */
#endif /* LYNXCGI_LINKS */
#ifdef REVERSE_CLEAR_SCREEN_PROBLEM
BOOLEAN enable_scrollback = TRUE;
#else
BOOLEAN enable_scrollback = FALSE;
#endif /* REVERSE_CLEAR_SCREEN_PROBLEM */
char empty_string[] =
{'\0'};
int display_lines; /* number of lines in display */
int www_search_result = -1;
/* linked list of printers */
lynx_list_item_type *printers = NULL;
/* linked list of download options */
lynx_list_item_type *downloaders = NULL;
/* linked list of upload options */
#ifdef USE_EXTERNALS
lynx_list_item_type *externals = NULL;
/* linked list of external options */
#endif
lynx_list_item_type *uploaders = NULL;
int LYShowColor = SHOW_COLOR_UNKNOWN; /* to show or not */
int LYrcShowColor = SHOW_COLOR_UNKNOWN; /* ... last used */
#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU)
BOOLEAN LYUseFormsOptions = TRUE; /* use forms-based options menu */
#endif
BOOLEAN LYJumpFileURL = FALSE; /* always FALSE the first time */
BOOLEAN LYPermitURL = FALSE;
BOOLEAN LYRestricted = FALSE; /* whether we have -anonymous option */
BOOLEAN LYShowCursor = SHOW_CURSOR; /* to show or not to show */
BOOLEAN LYUnderlineLinks = UNDERLINE_LINKS; /* Show the links underlined vs bold */
BOOLEAN LYUseDefShoCur = TRUE; /* Command line -show_cursor toggle */
BOOLEAN LYUserSpecifiedURL = TRUE; /* always TRUE the first time */
BOOLEAN LYValidate = FALSE;
BOOLEAN LYforce_no_cache = FALSE;
BOOLEAN LYinternal_flag = FALSE; /* override no-cache b/c internal link */
BOOLEAN LYoverride_no_cache = FALSE; /*override no-cache b/c history etc */
BOOLEAN LYresubmit_posts = ALWAYS_RESUBMIT_POSTS;
BOOLEAN LYtrimInputFields = FALSE;
BOOLEAN LYxhtml_parsing = FALSE;
BOOLEAN bold_H1 = FALSE;
BOOLEAN bold_headers = FALSE;
BOOLEAN bold_name_anchors = FALSE;
BOOLEAN case_sensitive = CASE_SENSITIVE_ALWAYS_ON;
BOOLEAN check_mail = CHECKMAIL;
BOOLEAN child_lynx = FALSE;
BOOLEAN dump_links_only = FALSE;
BOOLEAN dump_output_immediately = FALSE;
BOOLEAN dump_to_stderr = FALSE;
BOOLEAN emacs_keys = EMACS_KEYS_ALWAYS_ON;
BOOLEAN error_logging = MAIL_SYSTEM_ERROR_LOGGING;
BOOLEAN goto_buffer = GOTOBUFFER; /* TRUE if offering default goto URL */
BOOLEAN historical_comments = FALSE;
BOOLEAN is_www_index = FALSE;
BOOLEAN jump_buffer = JUMPBUFFER; /* TRUE if offering default shortcut */
BOOLEAN lynx_mode = NORMAL_LYNX_MODE;
BOOLEAN minimal_comments = FALSE;
BOOLEAN number_fields_on_left = TRUE;
BOOLEAN number_links_on_left = TRUE;
BOOLEAN recent_sizechange = FALSE; /* the window size changed recently? */
BOOLEAN soft_dquotes = FALSE;
BOOLEAN use_underscore = SUBSTITUTE_UNDERSCORES;
BOOLEAN verbose_img = VERBOSE_IMAGES; /* show filenames or not */
BOOLEAN vi_keys = VI_KEYS_ALWAYS_ON;
int keypad_mode = DEFAULT_KEYPAD_MODE;
int user_mode = NOVICE_MODE;
BOOLEAN telnet_ok = TRUE;
#ifndef DISABLE_NEWS
BOOLEAN news_ok = TRUE;
#endif
BOOLEAN rlogin_ok = TRUE;
BOOLEAN long_url_ok = FALSE;
BOOLEAN ftp_ok = TRUE;
BOOLEAN system_editor = FALSE;
BOOLEAN had_restrictions_default = FALSE;
BOOLEAN had_restrictions_all = FALSE;
BOOLEAN exec_frozen = FALSE;
BOOLEAN no_bookmark = FALSE;
BOOLEAN no_bookmark_exec = FALSE;
BOOLEAN no_chdir = FALSE;
BOOLEAN no_disk_save = FALSE;
BOOLEAN no_dotfiles = NO_DOT_FILES;
BOOLEAN no_download = FALSE;
BOOLEAN no_editor = FALSE;
BOOLEAN no_exec = FALSE;
BOOLEAN no_file_url = FALSE;
BOOLEAN no_goto = FALSE;
BOOLEAN no_goto_configinfo = FALSE;
BOOLEAN no_goto_cso = FALSE;
BOOLEAN no_goto_file = FALSE;
BOOLEAN no_goto_finger = FALSE;
BOOLEAN no_goto_ftp = FALSE;
BOOLEAN no_goto_gopher = FALSE;
BOOLEAN no_goto_http = FALSE;
BOOLEAN no_goto_https = FALSE;
BOOLEAN no_goto_lynxcgi = FALSE;
BOOLEAN no_goto_lynxexec = FALSE;
BOOLEAN no_goto_lynxprog = FALSE;
BOOLEAN no_goto_mailto = FALSE;
BOOLEAN no_goto_rlogin = FALSE;
BOOLEAN no_goto_telnet = FALSE;
BOOLEAN no_goto_tn3270 = FALSE;
BOOLEAN no_goto_wais = FALSE;
BOOLEAN no_inside_ftp = FALSE;
BOOLEAN no_inside_rlogin = FALSE;
BOOLEAN no_inside_telnet = FALSE;
BOOLEAN no_jump = FALSE;
BOOLEAN no_lynxcfg_info = FALSE;
BOOLEAN no_lynxcgi = FALSE;
BOOLEAN no_mail = FALSE;
BOOLEAN no_multibook = FALSE;
BOOLEAN no_option_save = FALSE;
BOOLEAN no_outside_ftp = FALSE;
BOOLEAN no_outside_rlogin = FALSE;
BOOLEAN no_outside_telnet = FALSE;
BOOLEAN no_print = FALSE;
BOOLEAN no_shell = FALSE;
BOOLEAN no_suspend = FALSE;
BOOLEAN no_telnet_port = FALSE;
BOOLEAN no_useragent = FALSE;
#ifndef DISABLE_FTP
BOOLEAN ftp_passive = FTP_PASSIVE; /* TRUE if doing ftp in passive mode */
BOOLEAN ftp_local_passive;
HTList *broken_ftp_epsv = NULL;
HTList *broken_ftp_retr = NULL;
char *ftp_lasthost = NULL;
#endif
#ifndef DISABLE_NEWS
BOOLEAN no_goto_news = FALSE;
BOOLEAN no_goto_nntp = FALSE;
BOOLEAN no_goto_snews = FALSE;
BOOLEAN no_inside_news = FALSE;
BOOLEAN no_newspost = FALSE;
BOOLEAN no_outside_news = FALSE;
#endif
#ifdef USE_EXTERNALS
BOOLEAN no_externals = FALSE;
#endif
#ifndef NO_CONFIG_INFO
BOOLEAN no_lynxcfg_xinfo = FALSE;
#ifdef HAVE_CONFIG_H
BOOLEAN no_compileopts_info = FALSE;
#endif
#endif
BOOLEAN no_statusline = FALSE;
BOOLEAN no_filereferer = TRUE;
char LYRefererWithQuery = 'D'; /* 'D' for drop */
BOOLEAN local_host_only = FALSE;
BOOLEAN override_no_download = FALSE;
BOOLEAN show_dotfiles = FALSE; /* From rcfile if no_dotfiles is false */
BOOLEAN LYforce_HTML_mode = FALSE;
BOOLEAN LYfind_leaks = TRUE;
#ifdef __DJGPP__
BOOLEAN watt_debug = FALSE; /* WATT-32 debugging */
BOOLEAN dj_is_bash = FALSE; /* Check for bash shell under DJGPP */
#endif /* __DJGPP__ */
#ifdef WIN_EX
BOOLEAN focus_window = FALSE; /* 1998/10/05 (Mon) 17:18:42 */
char windows_drive[4]; /* 1998/01/13 (Tue) 21:13:24 */
#endif
#ifdef _WINDOWS
#define TIMEOUT 180 /* 1998/03/30 (Mon) 14:50:44 */
int lynx_timeout = TIMEOUT;
CRITICAL_SECTION critSec_DNS; /* 1998/09/03 (Thu) 22:01:56 */
CRITICAL_SECTION critSec_READ; /* 1998/09/03 (Thu) 22:01:56 */
#endif /* _WINDOWS */
#if defined(WIN_EX)
BOOLEAN system_is_NT = FALSE;
#endif
BOOLEAN show_cfg = FALSE;
BOOLEAN no_table_center = FALSE; /* 1998/10/09 (Fri) 15:12:49 */
#if USE_BLAT_MAILER
BOOLEAN mail_is_blat = TRUE;
#endif
#ifdef USE_BLINK
# ifdef __EMX__
BOOLEAN term_blink_is_boldbg = TRUE;
# else
BOOLEAN term_blink_is_boldbg = FALSE;
# endif
#endif
BOOLEAN HEAD_request = FALSE;
BOOLEAN LYAcceptAllCookies = ACCEPT_ALL_COOKIES; /* take all cookies? */
BOOLEAN LYCancelledFetch = FALSE; /* TRUE if cancelled binary fetch */
BOOLEAN LYCollapseBRs = COLLAPSE_BR_TAGS; /* Collapse serial BRs? */
BOOLEAN LYDefaultRawMode;
BOOLEAN LYListNewsDates = LIST_NEWS_DATES;
BOOLEAN LYListNewsNumbers = LIST_NEWS_NUMBERS;
BOOLEAN LYMBMBlocked = BLOCK_MULTI_BOOKMARKS;
BOOLEAN LYNewsPosting = NEWS_POSTING; /* News posting supported? */
BOOLEAN LYNoFromHeader = TRUE; /* Never send From header? */
BOOLEAN LYNoRefererForThis = FALSE; /* No Referer header for this URL? */
BOOLEAN LYNoRefererHeader = FALSE; /* Never send Referer header? */
BOOLEAN LYRawMode;
BOOLEAN LYSelectPopups = USE_SELECT_POPUPS;
BOOLEAN LYSendUserAgent = SEND_USERAGENT; /* send Lynx User-Agent header? */
BOOLEAN LYSetCookies = SET_COOKIES; /* Process Set-Cookie headers? */
BOOLEAN LYUseDefSelPop = TRUE; /* Command line -popup toggle */
BOOLEAN LYUseDefaultRawMode = TRUE;
BOOLEAN LYUseMouse = FALSE;
BOOLEAN LYisConfiguredForX = FALSE;
BOOLEAN UCForce8bitTOUPPER = FALSE; /* override locale for case-conversion? */
BOOLEAN UCSaveBookmarksInUnicode = FALSE;
BOOLEAN bookmark_start = FALSE;
BOOLEAN check_realm = FALSE; /* Restrict to the starting realm? */
BOOLEAN clickable_images = MAKE_LINKS_FOR_ALL_IMAGES;
BOOLEAN crawl = FALSE; /* Do crawl? */
BOOLEAN keep_mime_headers = FALSE; /* Include mime headers with source dump */
BOOLEAN more_text = FALSE; /* is there more text to display? */
BOOLEAN more_links = FALSE; /* Links beyond a displayed page with no links? */
BOOLEAN no_list = FALSE;
BOOLEAN no_margins = FALSE;
BOOLEAN no_pause = FALSE;
BOOLEAN no_title = FALSE;
BOOLEAN no_url_redirection = FALSE; /* Don't follow URL redirections */
BOOLEAN pseudo_inline_alts = MAKE_PSEUDO_ALTS_FOR_INLINES;
BOOLEAN scan_for_buried_news_references = TRUE;
BOOLEAN startfile_ok = FALSE;
static BOOLEAN startfile_stdin = FALSE;
BOOLEAN traversal = FALSE; /* Do traversals? */
char *BookmarkPage = NULL; /* the name of the current bookmark page */
char *LYCookieAcceptDomains = NULL; /* domains to accept all cookies */
char *LYCookieLooseCheckDomains = NULL; /* check loosely */
char *LYCookieQueryCheckDomains = NULL; /* check w/a query */
char *LYCookieRejectDomains = NULL; /* domains to reject all cookies */
char *LYCookieSAcceptDomains = NULL; /* domains to accept all cookies */
char *LYCookieSLooseCheckDomains = NULL; /* check loosely */
char *LYCookieSQueryCheckDomains = NULL; /* check w/a query */
char *LYCookieSRejectDomains = NULL; /* domains to reject all cookies */
char *LYCookieSStrictCheckDomains = NULL; /* check strictly */
char *LYCookieStrictCheckDomains = NULL; /* check strictly */
char *LYHostName = NULL; /* treat as a local host name */
char *LYLocalDomain = NULL; /* treat as a local domain tail */
char *LYUserAgent = NULL; /* Lynx User-Agent header */
char *LYUserAgentDefault = NULL; /* Lynx default User-Agent header */
char *LynxHome = NULL; /* the default Home HREF. */
char *LynxSigFile = NULL; /* Signature file, in or off home */
char *UCAssume_MIMEcharset = NULL;
char *URLDomainPrefixes = NULL;
char *URLDomainSuffixes = NULL;
char *anonftp_password = NULL; /* anonymous ftp password (default: email) */
char *authentication_info[2] =
{NULL, NULL}; /* Id:Password for protected documents */
char *bookmark_page = NULL; /* the name of the default bookmark page */
char *editor = NULL; /* the name of the current editor */
char *form_get_data = NULL; /* User data for get form */
char *form_post_data = NULL; /* User data for post form */
char *global_extension_map = NULL; /* global mime.types */
char *global_type_map = NULL; /* global mailcap */
char *helpfile = NULL; /* the main help file */
char *helpfilepath = NULL; /* the path to the help file set */
char *homepage = NULL; /* home page or main screen */
char *http_error_file = NULL; /* Place HTTP status code in this file */
char *indexfile = NULL; /* an index file if there is one */
char *jumpfile = NULL; /* the name of the default jumps file */
char *jumpprompt = NULL; /* the default jumps prompt */
char *language = NULL; /* preferred language */
char *lynx_cfg_file = NULL; /* location of active lynx.cfg */
char *lynx_cmd_logfile; /* file to write keystroke commands, if any */
char *lynx_cmd_script; /* file to read keystroke commands, if any */
char *lynx_save_space = NULL; /* The prefix for save to disk paths */
char *lynx_temp_space = NULL; /* The prefix for temporary file paths */
char *lynxjumpfile = NULL; /* the current jump file URL */
char *lynxlinksfile = NULL; /* the current visited links file URL */
char *lynxlistfile = NULL; /* the current list file URL */
char *original_dir = NULL; /* the original directory */
char *personal_extension_map = NULL; /* .mime.types */
char *personal_mail_address = NULL; /* the users mail address */
char *personal_type_map = NULL; /* .mailcap */
char *pref_charset = NULL; /* preferred character set */
char *proxyauth_info[2] =
{NULL, NULL}; /* Id:Password for protected proxy servers */
#ifdef USE_SESSIONS
BOOLEAN LYAutoSession = FALSE; /* enable/disable auto saving/restoring of */
/* session */
char *LYSessionFile = NULL; /* the session file from lynx.cfg */
char *session_file = NULL; /* the current session file */
char *sessionin_file = NULL; /* only resume session from this file */
char *sessionout_file = NULL; /* only save session to this file */
short session_limit = 250; /* maximal number of entries saved per */
/* session file, rest will be ignored */
#endif /* USE_SESSIONS */
char *startfile = NULL; /* the first file */
char *startrealm = NULL; /* the startfile realm */
char *system_mail = NULL; /* The path for sending mail */
char *system_mail_flags = NULL; /* Flags for sending mail */
char *x_display = NULL; /* display environment variable */
HistInfo *history;
int nhist = 0; /* number of used history entries */
int size_history; /* number of allocated history entries */
LinkInfo links[MAXLINKS];
BOOLEAN nomore = FALSE; /* display -more- string in statusline messages */
int AlertSecs; /* time-delay for HTAlert() messages */
int DebugSecs; /* time-delay for HTProgress messages */
int InfoSecs; /* time-delay for Information messages */
int LYMultiBookmarks = MULTI_BOOKMARK_SUPPORT;
int LYStatusLine = -1; /* Line for statusline() if > -1 */
int LYcols = DFT_COLS;
int LYlines = DFT_ROWS;
int MessageSecs; /* time-delay for important Messages */
int ReplaySecs; /* time-delay for command-scripts */
int crawl_count = 0; /* Starting number for lnk#.dat files in crawls */
int dump_output_width = 0;
int dump_server_status = 0;
int lynx_temp_subspace = 0; /* > 0 if we made temp-directory */
int max_cookies_domain = 50;
int max_cookies_global = 500;
int max_cookies_buffer = 4096;
int nlinks = 0; /* number of links in memory */
int outgoing_mail_charset = -1; /* translate mail to this charset */
#ifndef DISABLE_BIBP
BOOLEAN BibP_bibhost_available = FALSE; /* until check succeeds */
BOOLEAN BibP_bibhost_checked = FALSE; /* until LYCheckBibHost */
BOOLEAN no_goto_bibp = FALSE;
char *BibP_bibhost = NULL; /* local server for bibp: links */
char *BibP_globalserver = NULL; /* global server for bibp: links */
#endif
#ifdef USE_PERSISTENT_COOKIES
BOOLEAN persistent_cookies = FALSE; /* disabled by default! */
char *LYCookieFile = NULL; /* cookie read file */
char *LYCookieSaveFile = NULL; /* cookie save file */
#endif /* USE_PERSISTENT_COOKIES */
#ifdef EXP_NESTED_TABLES
BOOLEAN nested_tables =
#if defined(USE_COLOR_STYLE)
TRUE
#else
FALSE /* see 2001-08-15 */
#endif
;
#endif
BOOLEAN LYShowTransferRate = TRUE;
int LYTransferRate = rateKB;
int LYAcceptEncoding = encodingALL;
int LYAcceptMedia = mediaOpt1;
char *LYTransferName = NULL;
char *XLoadImageCommand = NULL; /* Default image viewer for X */
BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? */
int LYHiddenLinks = HIDDENLINKS_SEPARATE; /* Show hidden links? */
char *SSL_cert_file = NULL; /* Default CA CERT file */
int Old_DTD = NO;
static BOOLEAN DTD_recovery = NO;
#ifndef NO_LYNX_TRACE
FILE *LYTraceLogFP = NULL; /* Pointer for TRACE log */
#endif
char *LYTraceLogPath = NULL; /* Path for TRACE log */
BOOLEAN LYUseTraceLog = USE_TRACE_LOG; /* Use a TRACE log? */
BOOLEAN LYSeekFragMAPinCur = TRUE;
BOOLEAN LYSeekFragAREAinCur = TRUE;
BOOLEAN LYStripDotDotURLs = TRUE; /* Try to fix ../ in some URLs? */
BOOLEAN LYForceSSLCookiesSecure = FALSE;
BOOLEAN LYNoCc = FALSE;
BOOLEAN LYPreparsedSource = FALSE; /* Show source as preparsed? */
BOOLEAN LYPrependBaseToSource = TRUE;
BOOLEAN LYPrependCharsetToSource = TRUE;
BOOLEAN LYQuitDefaultYes = QUIT_DEFAULT_YES;
BOOLEAN dont_wrap_pre = FALSE;
int cookie_noprompt;
#ifdef USE_SSL
int ssl_noprompt = FORCE_PROMPT_DFT;
#endif
int connect_timeout = 18000; /*=180000*0.1 - used in HTDoConnect.*/
int reading_timeout = 18000; /*=180000*0.1 - used in HTDoConnect.*/
#ifdef USE_JUSTIFY_ELTS
BOOLEAN ok_justify = FALSE;
int justify_max_void_percent = 35;
#endif
#ifdef USE_LOCALE_CHARSET
BOOLEAN LYLocaleCharset = FALSE;
#endif
#ifndef NO_DUMP_WITH_BACKSPACES
BOOLEAN with_backspaces = FALSE;
#endif
#if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
int scrsize_x = 0;
int scrsize_y = 0;
#endif
BOOLEAN force_empty_hrefless_a = FALSE;
#ifdef TEXTFIELDS_MAY_NEED_ACTIVATION
BOOL textfields_need_activation = FALSE;
BOOLEAN textfields_activation_option = FALSE;
#endif
BOOLEAN textfield_prompt_at_left_edge = FALSE;
#ifdef MARK_HIDDEN_LINKS
char *hidden_link_marker = NULL;
#endif
#ifdef DISP_PARTIAL
BOOLEAN display_partial_flag = TRUE; /* Display document during download */
BOOLEAN debug_display_partial = FALSE; /* Show with MessageSecs delay */
int partial_threshold = -1; /* # of lines to be d/l'ed until we repaint */
#endif
BOOLEAN LYNonRestartingSIGWINCH = FALSE;
BOOLEAN LYReuseTempfiles = FALSE;
BOOLEAN LYUseBuiltinSuffixes = TRUE;
#ifdef MISC_EXP
int LYNoZapKey = 0; /* 0: off (do z checking), 1: full, 2: initially */
#endif
#ifndef DISABLE_NEWS
#include <HTNews.h>
#endif
BOOLEAN FileInitAlreadyDone = FALSE;
static BOOLEAN stack_dump = FALSE;
static char *terminal = NULL;
static const char *pgm;
static BOOLEAN no_numbers = FALSE;
static BOOLEAN number_links = FALSE;
static BOOLEAN number_fields = FALSE;
static BOOLEAN LYPrependBase = FALSE;
static HTList *LYStdinArgs = NULL;
HTList *positionable_editor = NULL;
#ifndef EXTENDED_OPTION_LOGIC
/* if set then '--' will be recognized as the end of options */
#define EXTENDED_OPTION_LOGIC 1
#endif
#ifndef EXTENDED_STARTFILE_RECALL
/* if set then additional non-option args (before the last one) will be
made available for 'g'oto recall - kw */
#define EXTENDED_STARTFILE_RECALL 1
#endif
#if EXTENDED_STARTFILE_RECALL
static char *nonoption = 0;
#endif
#ifndef OPTNAME_ALLOW_DASHES
/* if set, then will allow dashes and underscores to be used interchangeable
in commandline option's names - VH */
#define OPTNAME_ALLOW_DASHES 1
#endif
static BOOL parse_arg(char **arg, unsigned mask, int *countp);
static void print_help_and_exit(int exit_status) GCC_NORETURN;
static void print_help_strings(const char *name,
const char *help,
const char *value,
BOOLEAN option);
#ifndef VMS
BOOLEAN LYNoCore = NO_FORCED_CORE_DUMP;
BOOLEAN restore_sigpipe_for_children = FALSE;
static void FatalProblem(int sig);
#endif /* !VMS */
#if defined(USE_COLOR_STYLE)
char *lynx_lss_file2 = NULL; /* from command-line options */
char *lynx_lss_file = NULL; /* from config-file, etc. */
#endif
#ifdef USE_DEFAULT_COLORS
BOOLEAN LYuse_default_colors = TRUE;
#endif
#ifdef __DJGPP__
static void LY_set_ctrl_break(int setting)
{
(void) signal(SIGINT, (setting ? SIG_DFL : SIG_IGN));
setcbrk(setting);
}
static int LY_get_ctrl_break(void)
{
__dpmi_regs regs;
regs.h.ah = 0x33;
regs.h.al = 0x00;
__dpmi_int(0x21, ®s);
return ((int) regs.h.dl);
}
static void reset_break(void)
{
LY_set_ctrl_break(init_ctrl_break[0]);
}
#endif /* __DJGPP__ */
#if defined(WIN_EX)
static int is_windows_nt(void)
{
DWORD version;
version = GetVersion();
if ((version & 0x80000000) == 0)
return 1;
else
return 0;
}
#endif
#ifdef LY_FIND_LEAKS
static void free_lynx_globals(void)
{
int i;
FREE(ftp_format);
#ifndef VMS
FREE(list_format);
#ifdef LYNXCGI_LINKS /* WebSter Mods -jkt */
FREE(LYCgiDocumentRoot);
#endif /* LYNXCGI_LINKS */
free_lynx_cfg();
#endif /* !VMS */
#ifdef SYSLOG_REQUESTED_URLS
FREE(syslog_txt);
#endif
#ifdef VMS
Define_VMSLogical("LYNX_VERSION", "");
#endif /* VMS */
#ifndef VMS
FREE(lynx_version_putenv_command);
#endif
#if USE_VMS_MAILER
FREE(mail_adrs);
#endif
FREE(LynxHome);
FREE(history);
FREE(homepage);
FREE(original_dir);
FREE(startfile);
FREE(helpfile);
FREE(helpfilepath);
FREE(jumpprompt);
#ifdef JUMPFILE
FREE(jumpfile);
#endif /* JUMPFILE */
FREE(indexfile);
FREE(x_display);
FREE(global_type_map);
FREE(personal_type_map);
FREE(global_extension_map);
FREE(personal_extension_map);
FREE(language);
FREE(pref_charset);
FREE(LynxSigFile);
FREE(system_mail);
FREE(system_mail_flags);
#ifndef DISABLE_BIBP
FREE(BibP_bibhost);
FREE(BibP_globalserver);
#endif
#ifdef USE_PERSISTENT_COOKIES
FREE(LYCookieFile);
FREE(LYCookieSaveFile);
#endif
FREE(LYCookieAcceptDomains);
FREE(LYCookieRejectDomains);
FREE(LYCookieLooseCheckDomains);
FREE(LYCookieStrictCheckDomains);
FREE(LYCookieQueryCheckDomains);
FREE(LYUserAgent);
FREE(LYUserAgentDefault);
FREE(LYHostName);
FREE(LYLocalDomain);
FREE(lynx_save_space);
FREE(bookmark_page);
FREE(BookmarkPage);
for (i = 0; i <= MBM_V_MAXFILES; i++) {
FREE(MBM_A_subbookmark[i]);
FREE(MBM_A_subdescript[i]);
}
FREE(editor);
FREE(authentication_info[0]);
FREE(authentication_info[1]);
FREE(proxyauth_info[0]);
FREE(proxyauth_info[1]);
FREE(lynxjumpfile);
#ifndef DISABLE_FTP
FREE(ftp_lasthost);
LYFreeStringList(broken_ftp_epsv);
LYFreeStringList(broken_ftp_retr);
#endif
FREE(startrealm);
FREE(personal_mail_address);
FREE(anonftp_password);
FREE(URLDomainPrefixes);
FREE(URLDomainSuffixes);
FREE(XLoadImageCommand);
FREE(lynx_temp_space);
FREE(LYTransferName);
FREE(LYTraceLogPath);
FREE(lynx_cfg_file);
#if defined(USE_COLOR_STYLE)
FREE(lynx_lss_file2);
FREE(lynx_lss_file);
#endif
FREE(UCAssume_MIMEcharset);
LYUIPages_free();
LYFreeHilites(0, nlinks);
nlinks = 0;
LYFreeStringList(LYcommandList());
HTInitProgramPaths();
#if EXTENDED_STARTFILE_RECALL
FREE(nonoption);
#endif
LYFreeStringList(positionable_editor);
return;
}
#endif /* LY_FIND_LEAKS */
/*
* This function frees the LYStdinArgs list. - FM
*/
static void LYStdinArgs_free(void)
{
LYFreeStringList(LYStdinArgs);
LYStdinArgs = NULL;
}
void reset_signals(void)
{
#ifndef NOSIGHUP
(void) signal(SIGHUP, SIG_DFL);
#endif /* NOSIGHUP */
(void) signal(SIGTERM, SIG_DFL);
#ifndef VMS
(void) signal(SIGINT, SIG_DFL);
#endif /* !VMS */
#ifdef SIGTSTP
if (no_suspend)
(void) signal(SIGTSTP, SIG_DFL);
#endif /* SIGTSTP */
}
void exit_immediately(int code)
{
reset_signals();
exit(code);
}
#ifdef EBCDIC
static void FixCharacters(void)
{
int c;
int work1[256], work2[256];
for (c = 0; c < 256; c++) {
work1[c] = keymap[c + 1];
work2[c] = key_override[c + 1];
}
for (c = 0; c < 256; c++) {
keymap[IBM1047[c] + 1] = work1[c];
key_override[IBM1047[c] + 1] = work2[c];
}
}
#endif /* EBCDIC */
static BOOL GetStdin(char **buf,
BOOL marker)
{
if (LYSafeGets(buf, stdin) != 0
&& (!marker || strncmp(*buf, "---", 3) != 0)) {
LYTrimTrailing(*buf);
CTRACE((tfp, "...data: %s\n", *buf));
return TRUE;
}
CTRACE((tfp, "...mark: %s\n", *buf ? *buf : ""));
return FALSE;
}
#ifdef WIN32
static BOOL cleanup_win32(DWORD fdwCtrlType)
{
switch (fdwCtrlType) {
case CTRL_CLOSE_EVENT:
cleanup_sig(-1);
return TRUE;
default:
return FALSE;
}
}
#endif
/*
* Append the SSL version to lynx version or user-agent string.
*/
#ifdef USE_SSL
static void append_ssl_version(char **target,
const char *separator)
{
char SSLLibraryVersion[256];
char *SSLcp;
HTSprintf(target, " SSL-MM%s1.4.1", separator);
#undef LYNX_SSL_VERSION
#if defined(SSLEAY_VERSION)
#define LYNX_SSL_VERSION SSLeay_version(SSLEAY_VERSION)
#else
#if defined(OPENSSL_VERSION_TEXT)
#define LYNX_SSL_VERSION OPENSSL_VERSION_TEXT
#else
#if defined(GNUTLS_VERSION)
#define LYNX_SSL_VERSION GNUTLS_VERSION
#endif /* GNUTLS_VERSION */
#endif /* OPENSSL_VERSION_TEXT */
#endif
#ifdef LYNX_SSL_VERSION
if (*separator == ' ')
StrAllocCat(*target, ",");
LYstrncpy(SSLLibraryVersion, LYNX_SSL_VERSION, sizeof(SSLLibraryVersion) - 1);
if ((SSLcp = strchr(SSLLibraryVersion, ' ')) != NULL) {
*SSLcp++ = *separator;
if ((SSLcp = strchr(SSLcp, ' ')) != NULL) {
*SSLcp = '\0';
StrAllocCat(*target, " ");
StrAllocCat(*target, SSLLibraryVersion);
}
}
#endif /* LYNX_SSL_VERSION */
}
#endif /* USE_SSL */
static void SetLocale(void)
{
#ifdef LOCALE
/*
* LOCALE support for international characters.
*/
setlocale(LC_ALL, "");
#endif /* LOCALE */
/* Set the text message domain. */
#if defined(HAVE_LIBINTL_H) || defined(HAVE_LIBGETTEXT_H)
{
char *cp;
if ((cp = LYGetEnv("LYNX_LOCALEDIR")) == 0)
cp = LOCALEDIR;
bindtextdomain("lynx", cp);
textdomain("lynx");
}
#endif /* HAVE_LIBINTL_H */
}
/*
* Wow! Someone wants to start up Lynx.
*/
int main(int argc,
char **argv)
{
int i; /* indexing variable */
int status = 0; /* exit status */
char *temp = NULL;
char *cp;
FILE *fp;
struct stat dir_info;
char filename[LY_MAXPATH];
BOOL LYGetStdinArgs = FALSE;
#ifdef _WINDOWS
WSADATA WSAData;
#endif /* _WINDOWS */
/*
* Just in case someone has the idea to install lynx set-uid, let's try
* to discourage it.
*/
#if defined(GETUID) && defined(SETUID)
setuid(getuid());
#endif
#ifdef NOT_ASCII
FixCharacters();
#endif /* NOT_ASCII */
#ifndef DISABLE_FTP
/* malloc a sizeof(char) so 1st strcmp() won't dump in HTLoadFile() */
ftp_lasthost = typecalloc(char);
#endif
#ifdef USE_CHARSET_CHOICE
memset((char *) charset_subsets, 0, sizeof(charset_subset_t) * MAXCHARSETS);
#endif
#ifdef _WINDOWS
{
int err;
WORD wVerReq;
wVerReq = MAKEWORD(1, 1);
err = WSAStartup(wVerReq, &WSAData);
if (err != 0) {
puts(gettext("No Winsock found, sorry."));
sleep(5);
return 1;
}
}
/* 1998/09/03 (Thu) 22:02:32 */
InitializeCriticalSection(&critSec_DNS);
InitializeCriticalSection(&critSec_READ);
#endif /* _WINDOWS */
#if defined(WIN_EX)
/* 1997/10/19 (Sun) 21:40:54 */
system_is_NT = (BOOL) is_windows_nt();
/* 1998/01/13 (Tue) 21:13:47 */
GetWindowsDirectory(filename, sizeof filename);
windows_drive[0] = filename[0];
windows_drive[1] = filename[1];
windows_drive[2] = '\0';
#endif
#ifdef __DJGPP__
if (LY_get_ctrl_break() == 0) {
LY_set_ctrl_break(TRUE);
init_ctrl_break[0] = 0;
} else {
init_ctrl_break[0] = 1;
}
__djgpp_set_sigquit_key(0x082D); /* Bind ALT-X to SIGQUIT */
signal(SIGQUIT, cleanup_sig);
atexit(reset_break);
if (((cp = LYGetEnv("SHELL")) != NULL)
&& (strstr(LYPathLeaf(cp), "sh") != NULL))
dj_is_bash = TRUE;
#endif /* __DJGPP__ */
/*
* To prevent corrupting binary data on DOS, MS-WINDOWS or OS/2
* we open files and stdout in BINARY mode by default.
* Where necessary we should open and (close!) TEXT mode.
* (use LYNewTxtFile/LYAppendToTxtFile to open text files for writing)
*/
SetDefaultMode(O_BINARY);
SetOutputMode(O_BINARY);
#ifdef DOSPATH
if (LYGetEnv("TERM") == NULL)
putenv("TERM=vt100");
#endif
LYShowColor = (SHOW_COLOR ? SHOW_COLOR_ON : SHOW_COLOR_OFF);
/*
* Set up the argument list.
*/
pgm = argv[0];
cp = NULL;
if ((cp = LYLastPathSep(pgm)) != NULL) {
pgm = cp + 1;
}
/*
* Set up trace, the anonymous account defaults, validate restrictions,
* and/or the nosocks flag, if requested, and an alternate configuration
* file, if specified, NOW. Also, if we only want the help menu, output
* that and exit. - FM
*/
#ifndef NO_LYNX_TRACE
if (LYGetEnv("LYNX_TRACE") != 0) {
WWW_TraceFlag = TRUE;
}
#endif
/*
* Set up the TRACE log path, and logging if appropriate. - FM
*/
if ((cp = LYGetEnv("LYNX_TRACE_FILE")) == 0)
cp = FNAME_LYNX_TRACE;
LYTraceLogPath = typeMallocn(char, LY_MAXPATH);
LYAddPathToHome(LYTraceLogPath, LY_MAXPATH, cp);
/*
* Act on -version, -trace and -trace-mask NOW.
*/
for (i = 1; i < argc; i++) {
parse_arg(&argv[i], 1, &i);
}
LYOpenTraceLog();
#ifdef LY_FIND_LEAKS
/*
* Register the final function to be executed when being exited. Will
* display memory leaks if the -find-leaks option is used.
*/
atexit(LYLeaks);
/*
* Register the function which will free our allocated globals.
*/
atexit(free_lynx_globals);
#endif /* LY_FIND_LEAKS */
SetLocale();
/*
* Initialize our startup and global variables.
*/
#ifdef ULTRIX
/*
* Need this for Ultrix.
*/
terminal = LYGetEnv("TERM");
if ((terminal == NULL) || !strncasecomp(terminal, "xterm", 5))
terminal = "vt100";
#endif /* ULTRIX */
/*
* Zero the links and history struct arrays.
*/
memset((void *) links, 0, sizeof(LinkInfo) * MAXLINKS);
LYAllocHistory(8);
/*
* Zero the MultiBookmark arrays.
*/
memset((void *) MBM_A_subbookmark, 0, sizeof(char) * (MBM_V_MAXFILES + 1));
memset((void *) MBM_A_subdescript, 0, sizeof(char) * (MBM_V_MAXFILES + 1));
#ifndef VMS
StrAllocCopy(list_format, LIST_FORMAT);
#endif /* !VMS */
StrAllocCopy(ftp_format, FTP_FORMAT);
AlertSecs = SECS2Secs(ALERTSECS);
DebugSecs = SECS2Secs(DEBUGSECS);
InfoSecs = SECS2Secs(INFOSECS);
MessageSecs = SECS2Secs(MESSAGESECS);
ReplaySecs = SECS2Secs(REPLAYSECS);
StrAllocCopy(LYTransferName, "KiB");
StrAllocCopy(helpfile, HELPFILE);
StrAllocCopy(startfile, STARTFILE);
LYEscapeStartfile(&startfile);
StrAllocCopy(indexfile, DEFAULT_INDEX_FILE);
StrAllocCopy(global_type_map, GLOBAL_MAILCAP);
StrAllocCopy(personal_type_map, PERSONAL_MAILCAP);
StrAllocCopy(global_extension_map, GLOBAL_EXTENSION_MAP);
StrAllocCopy(personal_extension_map, PERSONAL_EXTENSION_MAP);
StrAllocCopy(language, PREFERRED_LANGUAGE);
StrAllocCopy(pref_charset, PREFERRED_CHARSET);
StrAllocCopy(system_mail, SYSTEM_MAIL);
#ifdef SYSTEM_MAIL_FLAGS
StrAllocCopy(system_mail_flags, SYSTEM_MAIL_FLAGS);
#else
StrAllocCopy(system_mail_flags, "");
#endif
StrAllocCopy(LYUserAgent, LYNX_NAME);
StrAllocCat(LYUserAgent, "/");
StrAllocCat(LYUserAgent, LYNX_VERSION);
if (HTLibraryVersion) {
StrAllocCat(LYUserAgent, " libwww-FM/");
StrAllocCat(LYUserAgent, HTLibraryVersion);
}
#ifdef USE_SSL
append_ssl_version(&LYUserAgent, "/");
#endif /* USE_SSL */
StrAllocCopy(LYUserAgentDefault, LYUserAgent);
#ifdef VMS
Define_VMSLogical("LYNX_VERSION", LYNX_VERSION);
#else
StrAllocCopy(lynx_version_putenv_command, "LYNX_VERSION=");
StrAllocCat(lynx_version_putenv_command, LYNX_VERSION);
(void) putenv(lynx_version_putenv_command);
/* Note: you must not free the data passed to 'putenv()' until you give it
* a new value for that variable.
*/
#endif /* VMS */
if ((cp = LYGetEnv("LYNX_TEMP_SPACE")) != NULL)
StrAllocCopy(lynx_temp_space, cp);
#if defined (UNIX) || defined (__DJGPP__)
else if ((cp = LYGetEnv("TMPDIR")) != NULL)
StrAllocCopy(lynx_temp_space, cp);
#endif
#if defined (DOSPATH) || defined (__EMX__)
else if ((cp = LYGetEnv("TEMP")) != NULL)
StrAllocCopy(lynx_temp_space, cp);
else if ((cp = LYGetEnv("TMP")) != NULL)
StrAllocCopy(lynx_temp_space, cp);
#endif
else
#ifdef TEMP_SPACE
StrAllocCopy(lynx_temp_space, TEMP_SPACE);
#else
{
puts(gettext("You MUST define a valid TMP or TEMP area!"));
exit_immediately(EXIT_FAILURE);
}
#endif
#ifdef WIN_EX /* for Windows 2000 ... 1999/08/23 (Mon) 08:24:35 */
if (access(lynx_temp_space, 0) != 0)
#endif
LYTildeExpand(&lynx_temp_space, TRUE);
if ((cp = strstr(lynx_temp_space, "$USER")) != NULL) {
char *cp1;
if ((cp1 = LYGetEnv("USER")) != NULL) {
*cp = '\0';
StrAllocCopy(temp, lynx_temp_space);
*cp = '$';
StrAllocCat(temp, cp1);
cp += 5;
StrAllocCat(temp, cp);
StrAllocCopy(lynx_temp_space, temp);
FREE(temp);
}
}
#ifdef VMS
LYLowerCase(lynx_temp_space);
if (strchr(lynx_temp_space, '/') != NULL) {
if (strlen(lynx_temp_space) == 1) {
StrAllocCopy(lynx_temp_space, "sys$scratch:");
} else {
LYAddPathSep(&lynx_temp_space);
StrAllocCopy(temp, HTVMS_name("", lynx_temp_space));
StrAllocCopy(lynx_temp_space, temp);
FREE(temp);
}
}
if (strchr(lynx_temp_space, ':') == NULL &&
strchr(lynx_temp_space, ']') == NULL) {
StrAllocCat(lynx_temp_space, ":");
}
#else
LYAddPathSep(&lynx_temp_space);
StrAllocCopy(lynx_temp_space, HTSYS_name(lynx_temp_space));
#endif /* VMS */
if ((HTStat(lynx_temp_space, &dir_info) < 0
#if defined(MULTI_USER_UNIX)
&& mkdir(lynx_temp_space, 0700) < 0
#endif
)
|| !S_ISDIR(dir_info.st_mode)) {
fprintf(stderr, "%s: %s\n",
lynx_temp_space,
gettext("No such directory"));
exit_immediately(EXIT_FAILURE);
}
#if USE_VMS_MAILER
#ifndef MAIL_ADRS
#define MAIL_ADRS "\"IN%%\"\"%s\"\"\""
#endif
StrAllocCopy(mail_adrs, MAIL_ADRS);
#endif
#ifdef LYNX_HOST_NAME
StrAllocCopy(LYHostName, LYNX_HOST_NAME);
#else
StrAllocCopy(LYHostName, HTHostName());
#endif /* LYNX_HOST_NAME */
StrAllocCopy(LYLocalDomain, LOCAL_DOMAIN);
StrAllocCopy(URLDomainPrefixes, URL_DOMAIN_PREFIXES);
StrAllocCopy(URLDomainSuffixes, URL_DOMAIN_SUFFIXES);
StrAllocCopy(XLoadImageCommand, XLOADIMAGE_COMMAND);
StrAllocCopy(SSL_cert_file, SSL_CERT_FILE);
#ifndef DISABLE_BIBP
StrAllocCopy(BibP_globalserver, BIBP_GLOBAL_SERVER);
StrAllocCopy(BibP_bibhost, "http://bibhost/"); /* protocol specified. */
#endif
/*
* Disable news posting if the compilation-based LYNewsPosting value is
* FALSE. This may be changed further down via lynx.cfg or the
* -restriction command line switch. - FM
*/
#ifndef DISABLE_NEWS
no_newspost = (BOOL) (LYNewsPosting == FALSE);
#endif
for (i = 1; i < argc; i++) {
parse_arg(&argv[i], 2, &i);
}
/*
* If we have a lone "-" switch for getting arguments from stdin, get them
* NOW, and act on the relevant ones, saving the others into an HTList for
* handling after the other initializations. The primary purpose of this
* feature is to allow for the potentially very long command line that can
* be associated with post or get data. The original implementation
* required that the lone "-" be the only command line argument, but that
* precluded its use when the lynx command is aliased with other arguments.
* When interactive, the stdin input is terminated by by Control-D on Unix
* or Control-Z on VMS, and each argument is terminated by a RETURN. When
* the argument is -get_data or -post_data, the data are terminated by a
* "---" string, alone on the line (also terminated by RETURN). - FM
*/
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-") == 0) {
LYGetStdinArgs = TRUE;
break;
}
}
if (LYGetStdinArgs == TRUE) {
char *buf = NULL;
CTRACE((tfp, "processing stdin arguments\n"));
while (GetStdin(&buf, TRUE)) {
char *noargv[2];
noargv[0] = buf;
noargv[1] = NULL;
LYTrimTrailing(buf);
if (parse_arg(&noargv[0], 2, (int *) 0) == FALSE
&& buf[0] != '\0') {
char *argument = NULL;
if (LYStdinArgs == NULL) {
LYStdinArgs = HTList_new();
#ifdef LY_FIND_LEAKS
atexit(LYStdinArgs_free);
#endif
}
StrAllocCopy(argument, buf);
HTList_appendObject(LYStdinArgs, argument);
CTRACE((tfp, "...StdinArg:%s\n", argument));
} else {
CTRACE((tfp, "...complete:%s\n", buf));
}
}
CTRACE((tfp, "...done with stdin arguments\n"));
FREE(buf);
}
#ifdef SOCKS
if (socks_flag)
SOCKSinit(argv[0]);
#endif /* SOCKS */
/*
* If we had -validate set all of the restrictions and disallow a TRACE log
* NOW. - FM
*/
if (LYValidate == TRUE) {
parse_restrictions("all");
LYUseTraceLog = FALSE;
}
/*
* If we didn't get and act on a -validate or -anonymous switch, but can
* verify that this is the anonymous account, set the default restrictions
* for that account and disallow a TRACE log NOW. - FM
*/
if (!LYValidate && !LYRestricted &&
strlen(ANONYMOUS_USER) > 0 &&
#if defined (VMS) || defined (NOUSERS)
!strcasecomp((LYGetEnv("USER") == NULL ? " " : LYGetEnv("USER")),
ANONYMOUS_USER)
#else
#ifdef HAVE_CUSERID
STREQ((char *) cuserid((char *) NULL), ANONYMOUS_USER)
#else
STREQ(((char *) getlogin() == NULL ? " " : getlogin()), ANONYMOUS_USER)
#endif /* HAVE_CUSERID */
#endif /* VMS */
) {
parse_restrictions("default");
LYRestricted = TRUE;
LYUseTraceLog = FALSE;
}
#ifdef USE_CMD_LOGGING
/*
* Open command-script, if specified
*/
if (lynx_cmd_script != 0) {
LYTildeExpand(&lynx_cmd_script, TRUE);
LYOpenCmdScript();
}
/*
* Open command-logging, if specified
*/
if (lynx_cmd_logfile != 0) {
LYTildeExpand(&lynx_cmd_logfile, TRUE);
LYOpenCmdLogfile(argc, argv);
}
#endif
/*
* Set up the default jump file stuff. - FM
*/
StrAllocCopy(jumpprompt, JUMP_PROMPT);
#ifdef JUMPFILE
StrAllocCopy(jumpfile, JUMPFILE);
{
temp = NULL;
HTSprintf0(&temp, "JUMPFILE:%s", jumpfile);
if (!LYJumpInit(temp)) {
CTRACE((tfp, "Failed to register %s\n", temp));
}
FREE(temp);
}
#endif /* JUMPFILE */
/*
* If no alternate configuration file was specified on the command line,
* see if it's in the environment.
*/
if (!lynx_cfg_file) {
if (((cp = LYGetEnv("LYNX_CFG")) != NULL) ||
(cp = LYGetEnv("lynx_cfg")) != NULL)
StrAllocCopy(lynx_cfg_file, cp);
}
/*
* If we still don't have a configuration file, use the userdefs.h
* definition.
*/
if (!lynx_cfg_file)
StrAllocCopy(lynx_cfg_file, LYNX_CFG_FILE);
#ifndef _WINDOWS /* avoid the whole ~ thing for now */
LYTildeExpand(&lynx_cfg_file, FALSE);
#endif
/*
* If the configuration file is not available, inform the user and exit.
*/
if (!LYCanReadFile(lynx_cfg_file)) {
fprintf(stderr,
gettext("\nConfiguration file \"%s\" is not available.\n\n"),
lynx_cfg_file);
exit_immediately(EXIT_FAILURE);
}
/*
* Make sure we have the character sets declared. This will initialize the
* CHARTRANS handling. - KW
*/
if (!LYCharSetsDeclared()) {
fprintf(stderr, gettext("\nLynx character sets not declared.\n\n"));
exit_immediately(EXIT_FAILURE);
}
/*
* (**) in Lynx, UCLYhndl_HTFile_for_unspec and UCLYhndl_for_unrec may be
* valid or not, but current_char_set and UCLYhndl_for_unspec SHOULD ALWAYS
* be a valid charset. Initialized here and may be changed later from
* lynx.cfg/command_line/options_menu. - LP (**)
*/
/*
* Set up the compilation default character set. - FM
*/
#ifdef CAN_AUTODETECT_DISPLAY_CHARSET
if (auto_display_charset >= 0)
current_char_set = auto_display_charset;
else
#endif
current_char_set = safeUCGetLYhndl_byMIME(CHARACTER_SET);
/*
* Set up HTTP default for unlabeled charset (iso-8859-1).
*/
UCLYhndl_for_unspec = LATIN1;
StrAllocCopy(UCAssume_MIMEcharset,
LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
/*
* Make sure we have the edit map declared. - FM
*/
if (!LYEditmapDeclared()) {
fprintf(stderr, gettext("\nLynx edit map not declared.\n\n"));
exit_immediately(EXIT_FAILURE);
}
#ifdef USE_COLOR_TABLE
/*
* Set up default foreground and background colors.
*/
lynx_setup_colors();
#endif /* USE_COLOR_TABLE */
/*
* Set the original directory, used for default download
*/
if (!strcmp(Current_Dir(filename), ".")) {
if ((cp = LYGetEnv("PWD")) != 0)
StrAllocCopy(original_dir, cp);
} else {
StrAllocCopy(original_dir, filename);
}
/*
* Set the compilation default signature file. - FM
*/
LYstrncpy(filename, LYNX_SIG_FILE, sizeof(filename) - 1);
if (LYPathOffHomeOK(filename, sizeof(filename))) {
StrAllocCopy(LynxSigFile, filename);
LYAddPathToHome(filename, sizeof(filename), LynxSigFile);
StrAllocCopy(LynxSigFile, filename);
CTRACE((tfp, "LYNX_SIG_FILE set to '%s'\n", LynxSigFile));
} else {
CTRACE((tfp, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", LYNX_SIG_FILE));
}
#ifdef USE_PRETTYSRC
/*this is required for checking the tagspecs when parsing cfg file by
LYReadCFG.c:parse_html_src_spec -HV */
HTSwitchDTD(TRUE);
#endif
/*
* Process the configuration file.
*/
read_cfg(lynx_cfg_file, "main program", 1, (FILE *) 0);
#if defined(USE_COLOR_STYLE)
/*
* A command-line "-lss" always overrides the config-file, even if it is
* an empty string such as -lss="".
*/
if (lynx_lss_file2 != 0) {
FREE(lynx_lss_file);
lynx_lss_file = lynx_lss_file2;
lynx_lss_file2 = 0;
}
/*
* If no alternate lynx-style file was specified on the command line, see
* if it's in the environment.
*/
if (!lynx_lss_file) {
if (((cp = LYGetEnv("LYNX_LSS")) != NULL) ||
(cp = LYGetEnv("lynx_lss")) != NULL)
StrAllocCopy(lynx_lss_file, cp);
}
/*
* If we still don't have a lynx-style file, use the userdefs.h definition.
*/
if (!lynx_lss_file)
StrAllocCopy(lynx_lss_file, LYNX_LSS_FILE);
LYTildeExpand(&lynx_lss_file, TRUE);
/*
* If the lynx-style file is not available, inform the user and exit.
*/
if (non_empty(lynx_lss_file) && !LYCanReadFile(lynx_lss_file)) {
fprintf(stderr, gettext("\nLynx file \"%s\" is not available.\n\n"),
lynx_lss_file);
exit_immediately(EXIT_FAILURE);
} else {
style_readFromFile(lynx_lss_file);
}
#endif /* USE_COLOR_STYLE */
/*
* Process the RC file.
*/
read_rc(NULL);
#ifdef USE_LOCALE_CHARSET
LYFindLocaleCharset();
#endif
/*
* Get WWW_HOME environment variable if it exists.
*/
if ((cp = LYGetEnv("WWW_HOME")) != NULL) {
StrAllocCopy(startfile, cp);
LYEscapeStartfile(&startfile);
}
/*
* Set the LynxHome URL. If it's a file URL and the
* host is defaulted, force in "//localhost", and if
* it's not an absolute URL, make it one. - FM
*/
StrAllocCopy(LynxHome, startfile);
LYEnsureAbsoluteURL(&LynxHome, "LynxHome", FALSE);
/*
* Process any command line arguments not already handled. - FM
* May set startfile as a side-effect.
*/
for (i = 1; i < argc; i++) {
parse_arg(&argv[i], 4, &i);
}
/*
* Process any stdin-derived arguments for a lone "-" which we've loaded
* into LYStdinArgs. - FM
*/
if (LYStdinArgs != NULL) {
char *my_args[2];
HTList *cur = LYStdinArgs;
my_args[1] = NULL;
while (NULL != (my_args[0] = (char *) HTList_nextObject(cur))) {
parse_arg(my_args, 4, (int *) 0);
}
LYStdinArgs_free();
}
#ifdef HAVE_TTYNAME
/*
* If the input is not a tty, we are either running in cron, or are
* getting input via a pipe:
*
* a) in cron, none of stdin/stdout/stderr are tty's.
* b) from a pipe, we should have either "-" or "-stdin" options.
*/
if (!LYGetStdinArgs
&& !startfile_stdin
&& !isatty(fileno(stdin))
&& (isatty(fileno(stdout) || isatty(fileno(stderr))))) {
int ignored = 0;
int ch;
while ((ch = fgetc(stdin)) != EOF) {
++ignored;
}
if (ignored) {
fprintf(stderr,
gettext("Ignored %d characters from standard input.\n"), ignored);
fprintf(stderr,
gettext("Use \"-stdin\" or \"-\" to tell how to handle piped input.\n"));
}
}
#endif /* HAVE_TTYNAME */
#ifdef CAN_SWITCH_DISPLAY_CHARSET
if (current_char_set == auto_display_charset) /* Better: explicit option */
switch_display_charsets = 1;
#endif
#if defined (TTY_DEVICE) || defined(HAVE_TTYNAME)
/*
* If we are told to read the startfile from standard input, do it now,
* after we have read all of the option data from standard input.
* Later we'll use LYReopenInput().
*/
if (startfile_stdin) {
char result[LY_MAXPATH];
char *buf = NULL;
CTRACE((tfp, "processing stdin startfile\n"));
if ((fp = LYOpenTemp(result, HTML_SUFFIX, "w")) != 0) {
StrAllocCopy(startfile, result);
while (GetStdin(&buf, FALSE)) {
fputs(buf, fp);
fputc('\n', fp);
}
FREE(buf);
LYCloseTempFP(fp);
}
CTRACE((tfp, "...done stdin startfile\n"));
}
#endif
/*
* Initialize other things based on the configuration read.
*/
#ifdef USE_PRETTYSRC
if ((!Old_DTD) != TRUE) /* skip if they are already initialized -HV */
#endif
HTSwitchDTD(!Old_DTD);
/*
* Set up the proper character set with the desired
* startup raw 8-bit or CJK mode handling. - FM
*/
HTMLUseCharacterSet(current_char_set);
#ifdef USE_PERSISTENT_COOKIES
/*
* Sod it, this looks like a reasonable place to load the
* cookies file, probably. - RP
*
* And to set LYCookieSaveFile. - BJP
*/
if (persistent_cookies) {
if (LYCookieFile == NULL) {
LYCookieFile = typeMallocn(char, LY_MAXPATH);
LYAddPathToHome(LYCookieFile, LY_MAXPATH, FNAME_LYNX_COOKIES);
} else {
LYTildeExpand(&LYCookieFile, FALSE);
}
LYLoadCookies(LYCookieFile);
}
/* tilde-expand LYCookieSaveFile */
if (LYCookieSaveFile != NULL) {
LYTildeExpand(&LYCookieSaveFile, FALSE);
}
/*
* In dump_output_immediately mode, LYCookieSaveFile defaults to
* /dev/null, otherwise it defaults to LYCookieFile.
*/
if (LYCookieSaveFile == NULL) {
if (dump_output_immediately) {
StrAllocCopy(LYCookieSaveFile, "/dev/null");
} else {
StrAllocCopy(LYCookieSaveFile, LYCookieFile);
}
}
#endif
/*
* Check for a help file URL in the environment. Overiding
* compiled-in default and configuration file setting, if found.
*/
if ((cp = LYGetEnv("LYNX_HELPFILE")) != NULL)
StrAllocCopy(helpfile, cp);
/*
* Set up our help and about file base paths. - FM
*/
StrAllocCopy(helpfilepath, helpfile);
if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath)
*cp = '\0';
LYAddHtmlSep(&helpfilepath);
/*
* Check for a save space path in the environment. If one was set in the
* configuration file, that one will be overridden. - FM
*/
if ((cp = LYGetEnv("LYNX_SAVE_SPACE")) != NULL)
StrAllocCopy(lynx_save_space, cp);
/*
* We have a save space path, make sure it's valid. - FM
*/
if (lynx_save_space && *lynx_save_space == '\0') {
FREE(lynx_save_space);
}
if (lynx_save_space) {
LYTildeExpand(&lynx_save_space, TRUE);
#ifdef VMS
LYLowerCase(lynx_save_space);
if (strchr(lynx_save_space, '/') != NULL) {
if (strlen(lynx_save_space) == 1) {
StrAllocCopy(lynx_save_space, "sys$login:");
} else {
LYAddPathSep(&lynx_save_space);
StrAllocCopy(temp, HTVMS_name("", lynx_save_space));
StrAllocCopy(lynx_save_space, temp);
FREE(temp);
}
}
if (strchr(lynx_save_space, ':') == NULL &&
strchr(lynx_save_space, ']') == NULL) {
StrAllocCat(lynx_save_space, ":");
}
#else
LYAddPathSep(&lynx_save_space);
#endif /* VMS */
}
/*
* Set up the file extension and mime type maps from src/HTInit.c and the
* global and personal mime.types and mailcap files. These will override
* any SUFFIX or VIEWER maps in userdefs.h or the configuration file, if
* they overlap.
*/
HTFormatInit();
if (!FileInitAlreadyDone)
HTFileInit();
if (!LYCheckUserAgent()) {
HTAlwaysAlert(gettext("Warning:"), UA_NO_LYNX_WARNING);
}
if (show_cfg) {
cleanup();
exit_immediately(EXIT_SUCCESS);
}
#ifdef USE_SLANG
if (LYShowColor >= SHOW_COLOR_ON &&
!(Lynx_Color_Flags & SL_LYNX_USE_COLOR)) {
Lynx_Color_Flags |= SL_LYNX_USE_COLOR;
} else if ((Lynx_Color_Flags & SL_LYNX_USE_COLOR) ||
LYGetEnv("COLORTERM") != NULL) {
if (LYShowColor != SHOW_COLOR_NEVER &&
LYShowColor != SHOW_COLOR_ALWAYS) {
LYShowColor = SHOW_COLOR_ON;
}
}
#endif /* USE_SLANG */
if (LYPreparsedSource) {
HTPreparsedFormatInit();
}
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
#ifdef NEVER_ALLOW_REMOTE_EXEC
if (local_exec) {
local_exec = FALSE;
local_exec_on_local_files = TRUE;
}
#endif /* NEVER_ALLOW_REMOTE_EXEC */
#endif /* EXEC_LINKS || EXEC_SCRIPTS */
if (emacs_keys)
set_emacs_keys();
if (vi_keys)
set_vi_keys();
if (no_numbers) {
number_links = FALSE;
number_fields = FALSE;
keypad_mode = NUMBERS_AS_ARROWS;
set_numbers_as_arrows();
}
if (crawl) {
/* No numbered links by default, as documented
in CRAWL.announce. - kw */
if (!number_links) {
keypad_mode = NUMBERS_AS_ARROWS;
}
}
if (!links_are_numbered()) {
if (number_fields)
keypad_mode = LINKS_AND_FIELDS_ARE_NUMBERED;
if (number_links)
keypad_mode = LINKS_ARE_NUMBERED;
set_numbers_as_arrows();
}
/*
* Check the -popup command line toggle. - FM
*/
if (LYUseDefSelPop == FALSE) {
LYSelectPopups = (BOOLEAN) !LYSelectPopups;
}
/*
* Check the -show_cursor command line toggle. - FM
*/
if (LYUseDefShoCur == FALSE) {
LYShowCursor = (BOOLEAN) !LYShowCursor;
}
/*
* Check the -base command line switch with -source. - FM
*/
if (LYPrependBase && HTOutputFormat == HTAtom_for("www/download")) {
LYPrependBaseToSource = TRUE;
}
/*
* Disable multiple bookmark support if not interactive, so it doesn't
* crash on curses functions, or if the support was blocked via userdefs.h
* and/or lynx.cfg, or via command line restrictions. - FM
*/
if (no_multibook)
LYMBMBlocked = TRUE;
if (dump_output_immediately || LYMBMBlocked || no_multibook) {
LYMultiBookmarks = MBM_OFF;
LYMBMBlocked = TRUE;
no_multibook = TRUE;
}
#ifdef USE_SOURCE_CACHE
/*
* Disable source caching if not interactive.
*/
if (dump_output_immediately)
LYCacheSource = SOURCE_CACHE_NONE;
#endif
#ifdef DISP_PARTIAL
/*
* Disable partial mode if not interactive.
*/
if (dump_output_immediately)
display_partial_flag = FALSE;
#endif
#ifdef VMS
set_vms_keys();
#endif /* VMS */
#if defined (__DJGPP__)
if (watt_debug)
dbug_init();
sock_init();
__system_flags =
__system_emulate_chdir | /* handle `cd' internally */
__system_handle_null_commands | /* ignore cmds with no effect */
__system_allow_long_cmds | /* handle commands > 126 chars */
__system_use_shell | /* use $SHELL if set */
__system_allow_multiple_cmds | /* allow `cmd1; cmd2; ...' */
__system_redirect; /* redirect internally */
/* This speeds up stat() tremendously */
_djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE;
#endif /* __DJGPP__ */
/* trap interrupts */
#ifdef WIN32
SetConsoleCtrlHandler((PHANDLER_ROUTINE) cleanup_win32, TRUE);
#endif
#ifndef NOSIGHUP
if (!dump_output_immediately)
(void) signal(SIGHUP, cleanup_sig);
#endif /* NOSIGHUP */
(void) signal(SIGTERM, cleanup_sig);
#ifdef SIGWINCH
LYExtSignal(SIGWINCH, size_change);
#endif /* SIGWINCH */
#ifndef VMS
if (!TRACE && !dump_output_immediately && !stack_dump) {
(void) signal(SIGINT, cleanup_sig);
#ifndef __linux__
#ifdef SIGBUS
(void) signal(SIGBUS, FatalProblem);
#endif /* SIGBUS */
#endif /* !__linux__ */
(void) signal(SIGSEGV, FatalProblem);
(void) signal(SIGILL, FatalProblem);
/*
* Since we're doing lots of TCP, just ignore SIGPIPE altogether.
*
* HTTCP.c should deal with a broken pipe for servers. Rick Mallet's
* check after c = GetChar() in LYStrings.c should deal with a
* disconnected terminal. So the runaway CPU time problem on Unix
* should not occur any more.
*/
#ifdef SIGPIPE
if (signal(SIGPIPE, SIG_IGN) != SIG_IGN)
restore_sigpipe_for_children = TRUE;
#endif /* SIGPIPE */
}
#endif /* !VMS */
#ifdef SIGTSTP
/*
* Block Control-Z suspending if requested. - FM
*/
if (no_suspend)
(void) signal(SIGTSTP, SIG_IGN);
#endif /* SIGTSTP */
/*
* Check for a valid HEAD request. - FM
*/
if (HEAD_request && LYCanDoHEAD(startfile) != TRUE) {
fprintf(stderr,
"The '-head' switch is for http HEAD requests and cannot be used for\n'%s'.\n",
startfile);
exit_immediately(EXIT_FAILURE);
}
/*
* Check for a valid MIME headers request. - FM
*/
if (keep_mime_headers && LYCanDoHEAD(startfile) != TRUE) {
fprintf(stderr,
"The '-mime_header' switch is for http URLs and cannot be used for\n'%s'.\n",
startfile);
exit_immediately(EXIT_FAILURE);
}
/*
* Check for a valid traversal request. - FM
*/
if (traversal && strncmp(startfile, "http", 4)) {
fprintf(stderr,
"The '-traversal' switch is for http URLs and cannot be used for\n'%s'.\n",
startfile);
exit_immediately(EXIT_FAILURE);
}
/*
* Finish setting up for an INTERACTIVE session. Done here so that URL
* guessing in LYEnsureAbsoluteURL() can be interruptible (terminal is in
* raw mode, select() works). -BL
*/
#ifdef USE_PRETTYSRC
if (!dump_output_immediately) {
HTMLSRC_init_caches(FALSE); /* do it before terminal is initialized */
#ifdef LY_FIND_LEAKS
atexit(html_src_clean_data);
#endif
}
#endif
if (!dump_output_immediately) {
setup(terminal);
}
/*
* If startfile is a file URL and the host is defaulted, force in
* "//localhost", and if it's not an absolute URL, make it one. - FM
*/
LYEnsureAbsoluteURL(&startfile, "STARTFILE", FALSE);
/*
* If homepage was specified and is a file URL with the host defaulted,
* force in "//localhost", and if it's not an absolute URL, make it one. -
* FM
*/
if (homepage) {
LYEnsureAbsoluteURL(&homepage, "HOMEPAGE", FALSE);
}
/*
* If we don't have a homepage specified, set it to startfile. Otherwise,
* reset LynxHome. - FM
*/
if (isEmpty(homepage)) {
StrAllocCopy(homepage, startfile);
} else {
StrAllocCopy(LynxHome, homepage);
}
/*
* Set up the inside/outside domain restriction flags. - FM
*/
if (inlocaldomain()) {
#if !defined(HAVE_UTMP) || defined(VMS) /* not selective */
telnet_ok = (BOOL) (!no_inside_telnet && !no_outside_telnet && telnet_ok);
#ifndef DISABLE_NEWS
news_ok = (BOOL) (!no_inside_news && !no_outside_news && news_ok);
#endif
ftp_ok = (BOOL) (!no_inside_ftp && !no_outside_ftp && ftp_ok);
rlogin_ok = (BOOL) (!no_inside_rlogin && !no_outside_rlogin && rlogin_ok);
#else
CTRACE((tfp, "LYMain: User in Local domain\n"));
telnet_ok = (BOOL) (!no_inside_telnet && telnet_ok);
#ifndef DISABLE_NEWS
news_ok = (BOOL) (!no_inside_news && news_ok);
#endif
ftp_ok = (BOOL) (!no_inside_ftp && ftp_ok);
rlogin_ok = (BOOL) (!no_inside_rlogin && rlogin_ok);
#endif /* !HAVE_UTMP || VMS */
} else {
CTRACE((tfp, "LYMain: User in REMOTE domain\n"));
telnet_ok = (BOOL) (!no_outside_telnet && telnet_ok);
#ifndef DISABLE_NEWS
news_ok = (BOOL) (!no_outside_news && news_ok);
#endif
ftp_ok = (BOOL) (!no_outside_ftp && ftp_ok);
rlogin_ok = (BOOL) (!no_outside_rlogin && rlogin_ok);
}
#ifdef DISABLE_FTP
ftp_ok = FALSE;
#else
/* predefine some known broken ftp servers */
LYSetConfigValue(RC_BROKEN_FTP_RETR, "ProFTPD 1.2.5");
LYSetConfigValue(RC_BROKEN_FTP_RETR, "spftp/");
LYSetConfigValue(RC_BROKEN_FTP_EPSV, "(Version wu-2.6.2-12)");
#endif
/*
* Make sure our bookmark default strings are all allocated and
* synchronized. - FM
*/
if (isEmpty(bookmark_page)) {
temp = NULL;
HTSprintf0(&temp, "lynx_bookmarks%s", HTML_SUFFIX);
set_default_bookmark_page(temp);
FREE(temp);
}
if (isEmpty(BookmarkPage)) {
set_default_bookmark_page(bookmark_page);
}
#if defined(SYSLOG_REQUESTED_URLS)
LYOpenlog(syslog_txt);
#endif
if (non_empty(x_display)) {
LYisConfiguredForX = TRUE;
}
/*
* Here's where we do all the work.
*/
if (dump_output_immediately) {
/*
* Finish setting up and start a NON-INTERACTIVE session. - FM
*/
if (crawl && !number_links && !number_fields) {
keypad_mode = NUMBERS_AS_ARROWS;
} else if (no_numbers) {
keypad_mode = NUMBERS_AS_ARROWS;
} else if (!no_list) {
if (!links_are_numbered()) {
if (number_fields)
keypad_mode = LINKS_AND_FIELDS_ARE_NUMBERED;
else
keypad_mode = LINKS_ARE_NUMBERED;
}
}
if (dump_output_width > 0) {
LYcols = dump_output_width;
}
/*
* Normal argument processing puts non-options (URLs) into the Goto
* history. Use this to dump all of the pages listed on the command
* line, or (if none are listed) via the startfile mechanism.
* history.
*/
#ifdef EXTENDED_STARTFILE_RECALL
HTAddGotoURL(startfile);
for (i = HTList_count(Goto_URLs) - 1; i >= 0; --i) {
StrAllocCopy(startfile, (char *) HTList_objectAt(Goto_URLs, i));
CTRACE((tfp, "dumping %d:%d %s\n",
i + 1, HTList_count(Goto_URLs), startfile));
status = mainloop();
if (!no_list &&
!crawl) /* For -crawl it has already been done! */
printlist(stdout, FALSE);
if (i != 0)
printf("\n");
}
#else
status = mainloop();
if (!no_list &&
!crawl && /* For -crawl it has already been done! */
links_are_numbered())
printlist(stdout, FALSE);
#endif
#ifdef USE_PERSISTENT_COOKIES
/*
* We want to save cookies picked up when in immediate dump mode.
* Instead of calling cleanup() here, let's only call this one. - BJP
*/
if (persistent_cookies)
LYStoreCookies(LYCookieSaveFile);
#endif /* USE_PERSISTENT_COOKIES */
exit_immediately(status);
} else {
/*
* Start an INTERACTIVE session. - FM
*/
#ifdef USE_COLOR_STYLE
cache_tag_styles();
#endif
#ifndef NO_DUMP_WITH_BACKSPACES
if (with_backspaces) {
/* we should warn about this somehow (nop for now) -VH */
with_backspaces = FALSE;
}
#endif
#ifndef ALL_CHARSETS_IN_O_MENU_SCREEN
init_charset_subsets();
#endif
ena_csi((BOOLEAN) (LYlowest_eightbit[current_char_set] > 155));
#ifdef USE_SESSIONS
RestoreSession();
#endif /* USE_SESSIONS */
status = mainloop();
LYCloseCloset(RECALL_URL);
LYCloseCloset(RECALL_MAIL);
#if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
if (!isendwin()) {
if ((saved_scrsize_x != 0) && (saved_scrsize_y != 0)) {
resize_term(saved_scrsize_y, saved_scrsize_x);
}
}
#endif
cleanup();
exit_immediately(status);
}
return (status); /* though redundant, for compiler-warnings */
}
/*
* Called by HTAccessInit to register any protocols supported by lynx.
* Protocols added by lynx:
* LYNXKEYMAP, lynxcgi, LYNXIMGMAP, LYNXCOOKIE, LYNXCACHE, LYNXMESSAGES
*/
#ifdef GLOBALREF_IS_MACRO
extern GLOBALREF (HTProtocol, LYLynxKeymap);
extern GLOBALREF (HTProtocol, LYLynxCGI);
extern GLOBALREF (HTProtocol, LYLynxIMGmap);
extern GLOBALREF (HTProtocol, LYLynxCookies);
#ifdef USE_CACHEJAR
extern GLOBALREF (HTProtocol, LYLynxCache);
#endif
extern GLOBALREF (HTProtocol, LYLynxStatusMessages);
#else
GLOBALREF HTProtocol LYLynxKeymap;
GLOBALREF HTProtocol LYLynxCGI;
GLOBALREF HTProtocol LYLynxIMGmap;
GLOBALREF HTProtocol LYLynxCookies;
#ifdef USE_CACHEJAR
GLOBALREF HTProtocol LYLynxCache;
#endif
GLOBALREF HTProtocol LYLynxStatusMessages;
#endif /* GLOBALREF_IS_MACRO */
void LYRegisterLynxProtocols(void)
{
HTRegisterProtocol(&LYLynxKeymap);
HTRegisterProtocol(&LYLynxCGI);
HTRegisterProtocol(&LYLynxIMGmap);
HTRegisterProtocol(&LYLynxCookies);
#ifdef USE_CACHEJAR
HTRegisterProtocol(&LYLynxCache);
#endif
HTRegisterProtocol(&LYLynxStatusMessages);
}
#ifndef NO_CONFIG_INFO
/*
* Some stuff to reload lynx.cfg without restarting new lynx session, also load
* options menu items and command-line options to make things consistent.
*
* Called by user of interactive session by LYNXCFG://reload/ link.
*
* Warning: experimental, more main() reorganization required.
* *Known* exceptions: persistent cookies, cookie files.
*
* Some aspects of COLOR (with slang?).
* Viewer stuff, mailcap files
* SUFFIX, mime.types files
* RULESFILE/RULE
*
* All work "somewhat", but not exactly as the first time.
*/
void reload_read_cfg(void)
{
char *tempfile;
FILE *rcfp;
/*
* no_option_save is always set for -anonymous and -validate. It is better
* to check for one or several specific restriction flags than for
* 'LYRestricted', which doesn't get set for individual restrictions or for
* -validate! However, no_option_save may not be the appropriate one to
* check - in that case, a new no_something should be added that gets
* automatically set for -anonymous and -validate (and whether it applies
* for -anonymous can be made installer- configurable in the usual way at
* the bottom of userdefs.h). - kw
*
*/
if (no_option_save) {
/* current logic requires(?) that saving user preferences is
possible. Additional applicable restrictions are already
checked by caller. - kw */
return;
}
/*
* Current user preferences are saved in a temporary file, to be read in
* again after lynx.cfg has been read. This avoids accidental changing of
* the preferences file. The regular preferences file doesn't even need to
* exist, and won't be created as a side effect of this function. Honoring
* the no_option_save restriction may thus be unnecessarily restrictive,
* but the check is currently still left in place. - kw
*/
tempfile = typecallocn(char, LY_MAXPATH);
if (!tempfile) {
HTAlwaysAlert(NULL, NOT_ENOUGH_MEMORY);
return;
}
rcfp = LYOpenTemp(tempfile, ".rc", "w");
if (rcfp == NULL) {
FREE(tempfile);
HTAlwaysAlert(NULL, CANNOT_OPEN_TEMP);
return;
}
if (!save_rc(rcfp)) {
HTAlwaysAlert(NULL, OPTIONS_NOT_SAVED);
LYRemoveTemp(tempfile);
FREE(tempfile);
return; /* can not write the very own file :( */
} {
/* set few safe flags: */
#ifdef USE_PERSISTENT_COOKIES
BOOLEAN persistent_cookies_flag = persistent_cookies;
char *LYCookieFile_flag = NULL;
char *LYCookieSaveFile_flag = NULL;
if (persistent_cookies) {
StrAllocCopy(LYCookieFile_flag, LYCookieFile);
StrAllocCopy(LYCookieSaveFile_flag, LYCookieSaveFile);
}
#endif
#ifdef USE_CHARSET_CHOICE
custom_assumed_doc_charset = FALSE;
custom_display_charset = FALSE;
memset((char *) charset_subsets, 0, sizeof(charset_subset_t) * MAXCHARSETS);
#endif
#ifdef USE_PRETTYSRC
html_src_on_lynxcfg_reload();
#endif
/* free downloaders, printers, environments, dired menu */
free_lynx_cfg();
#ifdef USE_SOURCE_CACHE
source_cache_file_error = FALSE; /* reset flag */
#endif
/*
* Process the configuration file.
*/
read_cfg(lynx_cfg_file, "main program", 1, (FILE *) 0);
/*
* Process the temporary RC file.
*/
rcfp = fopen(tempfile, "r");
read_rc(rcfp);
LYRemoveTemp(tempfile);
FREE(tempfile); /* done with it - kw */
#ifdef USE_CHARSET_CHOICE
init_charset_subsets();
#endif
/*
* Initialize other things based on the configuration read.
*/
LYSetDisplayLines();
/* Not implemented yet here,
* a major problem: file paths
* like lynx_save_space, LYCookieFile etc.
*/
#ifdef USE_PERSISTENT_COOKIES
/* restore old settings */
if (persistent_cookies != persistent_cookies_flag) {
persistent_cookies = persistent_cookies_flag;
HTAlert(gettext("persistent cookies state will be changed in next session only."));
}
if (persistent_cookies) {
if (strcmp(LYCookieFile, LYCookieFile_flag)) {
StrAllocCopy(LYCookieFile, LYCookieFile_flag);
CTRACE((tfp,
"cookie file can be changed in next session only, restored.\n"));
}
if (strcmp(LYCookieSaveFile, LYCookieSaveFile_flag)) {
StrAllocCopy(LYCookieSaveFile, LYCookieSaveFile_flag);
CTRACE((tfp,
"cookie save file can be changed in next session only, restored.\n"));
}
FREE(LYCookieFile_flag);
FREE(LYCookieSaveFile_flag);
}
#endif
}
}
#endif /* !NO_CONFIG_INFO */
static void force_dump_mode(void)
{
dump_output_immediately = TRUE;
no_pause = TRUE;
LYcols = DFT_COLS;
}
/* There are different ways of setting arguments on the command line, and
* there are different types of arguments. These include:
*
* -set_some_variable ==> some_variable = TRUE
* -toggle_some_variable ==> some_variable = !some_variable
* -some_variable=value ==> some_variable = value
*
* Others are complicated and require a function call.
*/
#define PARSE_SET(n,t,v,h) {n, t, UNION_SET(v), h}
#define PARSE_INT(n,t,v,h) {n, t, UNION_INT(v), h}
#define PARSE_STR(n,t,v,h) {n, t, UNION_STR(v), h}
#define PARSE_FUN(n,t,v,h) {n, t, UNION_FUN(v), h}
#define PARSE_NIL {NULL, 0, UNION_DEF(0), NULL}
typedef struct parse_args_type {
const char *name;
int type;
#define TOGGLE_ARG 0x0010
#define SET_ARG 0x0020
#define UNSET_ARG 0x0030
#define FUNCTION_ARG 0x0040
#define LYSTRING_ARG 0x0050
#define INT_ARG 0x0060
#define STRING_ARG 0x0070
#define TIME_ARG 0x0080
#define ARG_TYPE_MASK 0x0FF0
#define NEED_NEXT_ARG 0x1000
#define NEED_INT_ARG (NEED_NEXT_ARG | INT_ARG)
#define NEED_TIME_ARG (NEED_NEXT_ARG | TIME_ARG)
#define NEED_LYSTRING_ARG (NEED_NEXT_ARG | LYSTRING_ARG)
#define NEED_STRING_ARG (NEED_NEXT_ARG | STRING_ARG)
#define NEED_FUNCTION_ARG (NEED_NEXT_ARG | FUNCTION_ARG)
/* If the NEED_NEXT_ARG flags is set, and the option was not specified
* with an '=' character, then use the next argument in the argv list.
*/
ParseData;
const char *help_string;
} Config_Type;
/* -auth, -pauth */
static int parse_authentication(char *next_arg,
char **result)
{
/*
* Authentication information for protected documents.
*/
char *auth_info = 0;
if (next_arg != 0) {
StrAllocCopy(auth_info, next_arg);
memset(next_arg, ' ', strlen(next_arg)); /* Let's not show too much */
}
if (auth_info != 0) {
char *cp;
if ((cp = strchr(auth_info, ':')) != 0) { /* Pw */
*cp++ = '\0'; /* Terminate ID */
HTUnEscape(cp);
StrAllocCopy(result[1], cp);
}
if (*auth_info) { /* Id */
HTUnEscape(auth_info);
StrAllocCopy(result[0], auth_info);
}
FREE(auth_info);
}
return 0;
}
/* -anonymous */
static int anonymous_fun(char *next_arg GCC_UNUSED)
{
if (!LYValidate && !LYRestricted)
parse_restrictions("default");
LYRestricted = TRUE;
return 0;
}
/* -assume_charset */
static int assume_charset_fun(char *next_arg)
{
UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
StrAllocCopy(UCAssume_MIMEcharset,
LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
/* this may be a memory for bogus typo -
StrAllocCopy(UCAssume_MIMEcharset, next_arg);
LYLowerCase(UCAssume_MIMEcharset); */
return 0;
}
/* -assume_local_charset */
static int assume_local_charset_fun(char *next_arg)
{
UCLYhndl_HTFile_for_unspec = safeUCGetLYhndl_byMIME(next_arg);
return 0;
}
/* -assume_unrec_charset */
static int assume_unrec_charset_fun(char *next_arg)
{
UCLYhndl_for_unrec = safeUCGetLYhndl_byMIME(next_arg);
return 0;
}
/* -auth */
static int auth_fun(char *next_arg)
{
parse_authentication(next_arg, authentication_info);
return 0;
}
/* -base */
static int base_fun(char *next_arg GCC_UNUSED)
{
/*
* Treat -source equivalently to an interactive download with
* LYPrefixBaseToSource configured to TRUE, so that a BASE tag is prepended
* for text/html content types. We normally treat the module-wide global
* LYPrefixBaseToSource flag as FALSE with -source, but force it TRUE,
* later, if LYPrependBase is set TRUE here. - FM
*/
LYPrependBase = TRUE;
if (HTOutputFormat == HTAtom_for("www/dump"))
HTOutputFormat = HTAtom_for("www/download");
return 0;
}
/* -cache */
static int cache_fun(char *next_arg)
{
if (next_arg != 0)
HTCacheSize = atoi(next_arg);
/*
* Limit size.
*/
if (HTCacheSize < 2)
HTCacheSize = 2;
return 0;
}
/* -child */
static int child_fun(char *next_arg GCC_UNUSED)
{
child_lynx = TRUE;
no_disk_save = TRUE;
no_mail = TRUE;
return 0;
}
/* -child_relaxed */
static int child_relaxed_fun(char *next_arg GCC_UNUSED)
{
child_lynx = TRUE;
return 0;
}
#ifdef USE_SLANG
/* -color */
static int color_fun(char *next_arg GCC_UNUSED)
{
Lynx_Color_Flags |= SL_LYNX_USE_COLOR;
if (LYShowColor != SHOW_COLOR_ALWAYS)
LYShowColor = SHOW_COLOR_ON;
return 0;
}
#endif
#ifdef MISC_EXP
/* -convert_to */
static int convert_to_fun(char *next_arg)
{
if (next_arg != 0) {
char *outformat = NULL;
char *cp1, *cp2, *cp4;
int chndl;
StrAllocCopy(outformat, next_arg);
/* not lowercased, to allow for experimentation - kw */
/*LYLowerCase(outformat); */
if ((cp1 = strchr(outformat, ';')) != NULL) {
if ((cp2 = LYstrstr(cp1, "charset")) != NULL) {
cp2 += 7;
while (*cp2 == ' ' || *cp2 == '=' || *cp2 == '"')
cp2++;
for (cp4 = cp2; (*cp4 != '\0' && *cp4 != '"' &&
*cp4 != ';' &&
!WHITE(*cp4)); cp4++) ; /* do nothing */
*cp4 = '\0';
/* This is intentionally not the "safe" version,
to allow for experimentation. */
chndl = UCGetLYhndl_byMIME(cp2);
if (chndl < 0)
chndl = UCLYhndl_for_unrec;
if (chndl < 0) {
fprintf(stderr,
gettext("Lynx: ignoring unrecognized charset=%s\n"), cp2);
} else {
current_char_set = chndl;
}
*cp1 = '\0'; /* truncate outformat */
}
}
HTOutputFormat = HTAtom_for(outformat);
FREE(outformat);
} else {
HTOutputFormat = NULL;
}
return 0;
}
#endif
/* -crawl */
static int crawl_fun(char *next_arg GCC_UNUSED)
{
crawl = TRUE;
LYcols = DFT_COLS;
return 0;
}
/* -display */
static int display_fun(char *next_arg)
{
if (next_arg != 0) {
LYsetXDisplay(next_arg);
}
return 0;
}
/* -display_charset */
static int display_charset_fun(char *next_arg)
{
int i = UCGetLYhndl_byMIME(next_arg);
#ifdef CAN_AUTODETECT_DISPLAY_CHARSET
if (i < 0 && !strcasecomp(next_arg, "auto"))
i = auto_display_charset;
#endif
if (i < 0) { /* do nothing here: so fallback to lynx.cfg */
fprintf(stderr,
gettext("Lynx: ignoring unrecognized charset=%s\n"), next_arg);
} else
current_char_set = i;
return 0;
}
/* -dump */
static int dump_output_fun(char *next_arg GCC_UNUSED)
{
force_dump_mode();
return 0;
}
/* -editor */
static int editor_fun(char *next_arg)
{
if (next_arg != 0)
StrAllocCopy(editor, next_arg);
system_editor = TRUE;
return 0;
}
/* -error_file */
static int error_file_fun(char *next_arg)
{
/*
* Output return (success/failure) code of an HTTP transaction.
*/
if (next_arg != 0)
http_error_file = next_arg;
return 0;
}
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
/* -exec */
static int exec_fun(char *next_arg GCC_UNUSED)
{
#ifndef NEVER_ALLOW_REMOTE_EXEC
local_exec = TRUE;
#else
local_exec_on_local_files = TRUE;
#endif /* NEVER_ALLOW_REMOTE_EXEC */
return 0;
}
#endif
/* -get_data */
static int get_data_fun(char *next_arg GCC_UNUSED)
{
/*
* User data for GET form.
*/
char **get_data;
char *buf = NULL;
/*
* On Unix, conflicts with curses when interactive so let's force a dump.
* -CL
*
* On VMS, mods have been made in LYCurses.c to deal with potential
* conflicts, so don't force the dump here. - FM
*/
#ifndef VMS
force_dump_mode();
#endif /* VMS */
StrAllocCopy(form_get_data, "?"); /* Prime the pump */
get_data = &form_get_data;
/*
* Build GET data for later. Stop reading when we see a line with "---" as
* its first three characters.
*/
while (GetStdin(&buf, TRUE)) {
StrAllocCat(*get_data, buf);
}
CTRACE((tfp, "get_data:%s\n", *get_data));
CTRACE((tfp, "get_data:%s\n", form_get_data));
return 0;
}
/* -help */
static int help_fun(char *next_arg GCC_UNUSED)
{
print_help_and_exit(0);
return 0;
}
/* -hiddenlinks */
static int hiddenlinks_fun(char *next_arg)
{
/* *INDENT-OFF* */
static Config_Enum table[] = {
{ "merge", HIDDENLINKS_MERGE },
{ "listonly", HIDDENLINKS_SEPARATE },
{ "ignore", HIDDENLINKS_IGNORE },
{ NULL, -1 },
};
/* *INDENT-ON* */
if (next_arg != 0) {
if (!LYgetEnum(table, next_arg, &LYHiddenLinks))
print_help_and_exit(-1);
} else {
LYHiddenLinks = HIDDENLINKS_MERGE;
}
return 0;
}
/* -homepage */
static int homepage_fun(char *next_arg)
{
if (next_arg != 0) {
StrAllocCopy(homepage, next_arg);
LYEscapeStartfile(&homepage);
}
return 0;
}
/* -mime_header */
static int mime_header_fun(char *next_arg GCC_UNUSED)
{
/*
* Include mime headers and force source dump.
*/
keep_mime_headers = TRUE;
force_dump_mode();
HTOutputFormat = (LYPrependBase ?
HTAtom_for("www/download") : HTAtom_for("www/dump"));
LYcols = MAX_COLS;
return 0;
}
#ifndef DISABLE_NEWS
/* -newschunksize */
static int newschunksize_fun(char *next_arg)
{
if (next_arg != 0) {
HTNewsChunkSize = atoi(next_arg);
/*
* If the new HTNewsChunkSize exceeds the maximum,
* increase HTNewsMaxChunk to this size. - FM
*/
if (HTNewsChunkSize > HTNewsMaxChunk)
HTNewsMaxChunk = HTNewsChunkSize;
}
return 0;
}
/* -newsmaxchunk */
static int newsmaxchunk_fun(char *next_arg)
{
if (next_arg) {
HTNewsMaxChunk = atoi(next_arg);
/*
* If HTNewsChunkSize exceeds the new maximum,
* reduce HTNewsChunkSize to this maximum. - FM
*/
if (HTNewsChunkSize > HTNewsMaxChunk)
HTNewsChunkSize = HTNewsMaxChunk;
}
return 0;
}
#endif /* not DISABLE_NEWS */
/* -nobold */
static int nobold_fun(char *next_arg GCC_UNUSED)
{
LYnoVideo(1);
return 0;
}
/* -nobrowse */
static int nobrowse_fun(char *next_arg GCC_UNUSED)
{
HTDirAccess = HT_DIR_FORBID;
return 0;
}
/* -nocolor */
static int nocolor_fun(char *next_arg GCC_UNUSED)
{
LYShowColor = SHOW_COLOR_NEVER;
#ifdef USE_SLANG
Lynx_Color_Flags &= ~SL_LYNX_USE_COLOR;
Lynx_Color_Flags |= SL_LYNX_OVERRIDE_COLOR;
#endif
return 0;
}
/* -nopause */
static int nopause_fun(char *next_arg GCC_UNUSED)
{
no_pause = TRUE;
return 0;
}
/* -nomore */
static int nomore_fun(char *next_arg GCC_UNUSED)
{
nomore = TRUE;
return 0;
}
/* -noreverse */
static int noreverse_fun(char *next_arg GCC_UNUSED)
{
LYnoVideo(2);
return 0;
}
/* -nounderline */
static int nounderline_fun(char *next_arg GCC_UNUSED)
{
LYnoVideo(4);
return 0;
}
#ifdef MISC_EXP
/* -nozap */
static int nozap_fun(char *next_arg)
{
LYNoZapKey = 1; /* everything but "initially" treated as "full" - kw */
if (next_arg != 0) {
if (strcasecomp(next_arg, "initially") == 0)
LYNoZapKey = 2;
}
return 0;
}
#endif /* MISC_EXP */
/* -pauth */
static int pauth_fun(char *next_arg)
{
parse_authentication(next_arg, proxyauth_info);
return 0;
}
/* -post_data */
static int post_data_fun(char *next_arg GCC_UNUSED)
{
/*
* User data for POST form.
*/
char **post_data;
char *buf = NULL;
/*
* On Unix, conflicts with curses when interactive so let's force a dump.
* - CL
*
* On VMS, mods have been made in LYCurses.c to deal with potential
* conflicts, so don't force a dump here. - FM
*/
#ifndef VMS
force_dump_mode();
#endif /* VMS */
post_data = &form_post_data;
/*
* Build post data for later. Stop reading when we see a line with "---"
* as its first three characters.
*/
while (GetStdin(&buf, TRUE)) {
StrAllocCat(*post_data, buf);
}
return 0;
}
static const char *show_restriction(const char *name)
{
const char *value = 0;
switch (find_restriction(name, -1)) {
case TRUE:
value = "on";
break;
case FALSE:
value = "off";
break;
default:
value = "?";
break;
}
return value;
}
/* -restrictions */
static int restrictions_fun(char *next_arg)
{
/* *INDENT-OFF* */
static const struct {
const char *name;
const char *help;
} table[] = {
{ "all", "restricts all options." },
{ "bookmark", "disallow changing the location of the bookmark file" },
{ "bookmark_exec", "disallow execution links via the bookmark file" },
#if defined(DIRED_SUPPORT) && defined(OK_PERMIT)
{ "change_exec_perms", "\
disallow changing the eXecute permission on files\n\
(but still allow it for directories) when local file\n\
management is enabled." },
#endif /* DIRED_SUPPORT && OK_PERMIT */
#ifdef SUPPORT_CHDIR
{ "chdir", "\
disallow changing the working directory of lynx, e.g.,\n\
to affect the behavior of download command" },
#endif
#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO)
{ "compileopts_info", "\
disable info on options used to compile the binary" },
#endif
{ "default", "\
same as commandline option -anonymous. Sets the\n\
default service restrictions for anonymous users. Set to\n\
all restricted, except for: inside_telnet, outside_telnet,\n\
inside_ftp, outside_ftp, inside_rlogin, outside_rlogin,\n\
inside_news, outside_news, telnet_port, jump, mail, print,\n\
exec, and goto. The settings for these, as well as\n\
additional goto restrictions for specific URL schemes\n\
that are also applied, are derived from definitions\n\
within userdefs.h." },
#ifdef DIRED_SUPPORT
{ "dired_support", "disallow local file management" },
#endif /* DIRED_SUPPORT */
{ "disk_save", "disallow saving to disk in the download and print menus" },
{ "dotfiles", "disallow access to, or creation of, hidden (dot) files" },
{ "download", "disallow some downloaders in the download menu" },
{ "editor", "disallow editing" },
{ "exec", "disable execution scripts" },
{ "exec_frozen", "disallow the user from changing the execution link option" },
#ifdef USE_EXTERNALS
{ "externals", "disable passing URLs to some external programs" },
#endif
{ "file_url", "\
disallow using G)oto, served links or bookmarks for\n\
file: URL's" },
{ "goto", "disable the 'g' (goto) command" },
#if !defined(HAVE_UTMP) || defined(VMS) /* not selective */
{ "inside_ftp", "\
disallow ftps coming from inside your\n\
domain (utmp required for selectivity)" },
{ "inside_news", "\
disallow USENET news reading and posting coming\n\
from inside your domain (utmp required for selectivity)" },
{ "inside_rlogin", "\
disallow rlogins coming from inside your\n\
domain (utmp required for selectivity)" },
{ "inside_telnet", "\
disallow telnets coming from inside your\n\
domain (utmp required for selectivity)" },
#else
{ "inside_ftp", "\
disallow ftps coming from inside your domain" },
{ "inside_news", "\
disallow USENET news reading and posting coming\n\
from inside your domain" },
{ "inside_rlogin", "\
disallow rlogins coming from inside your domain" },
{ "inside_telnet", "\
disallow telnets coming from inside your domain" },
#endif /* HAVE_UTMP || VMS */
{ "jump", "disable the 'j' (jump) command" },
{ "lynxcfg_info", "\
disable viewing of lynx.cfg configuration file info" },
#ifndef NO_CONFIG_INFO
{ "lynxcfg_xinfo", "\
disable extended lynx.cfg viewing and reloading" },
#endif
{ "lynxcgi", "\
disallow execution of Lynx CGI URLs" },
{ "mail", "disallow mail" },
{ "multibook", "disallow multiple bookmark files" },
{ "news_post", "disallow USENET News posting." },
{ "option_save", "disallow saving options in .lynxrc" },
#if !defined(HAVE_UTMP) || defined(VMS) /* not selective */
{ "outside_ftp", "\
disallow ftps coming from outside your\n\
domain (utmp required for selectivity)" },
{ "outside_news", "\
disallow USENET news reading and posting coming\n\
from outside your domain (utmp required for selectivity)" },
{ "outside_rlogin", "\
disallow rlogins coming from outside your\n\
domain (utmp required for selectivity)" },
{ "outside_telnet", "\
disallow telnets coming from outside your\n\
domain (utmp required for selectivity)" },
#else
{ "outside_ftp", "\
disallow ftp coming from outside your domain" },
{ "outside_news", "\
disallow USENET news reading and posting coming\n\
from outside your domain" },
{ "outside_rlogin", "\
disallow rlogins coming from outside your domain" },
{ "outside_telnet", "\
disallow telnets coming from outside your domain" },
#endif /* !HAVE_UTMP || VMS */
{ "print", "disallow most print options" },
{ "shell", "\
disallow shell escapes, and lynxexec, lynxprog or lynxcgi\n\
G)oto's" },
{ "suspend", "disallow Control-Z suspends with escape to shell" },
{ "telnet_port", "disallow specifying a port in telnet G)oto's" },
{ "useragent", "disallow modifications of the User-Agent header" },
};
/* *INDENT-ON* */
static const char *Usage[] =
{
""
,"USAGE: lynx -restrictions=[option][,option][,option]"
,"List of Options:"
," ? when used alone, list restrictions in effect."
};
unsigned j, k, column = 0;
const char *name;
const char *value;
BOOLEAN found, first;
if (isEmpty(next_arg)) {
SetOutputMode(O_TEXT);
for (j = 0; j < TABLESIZE(Usage); j++) {
printf("%s\n", Usage[j]);
}
for (j = 0; j < TABLESIZE(table); j++) {
if (!strcmp(table[j].name, "all")
|| !strcmp(table[j].name, "default")) {
value = NULL;
} else {
value = show_restriction(table[j].name);
}
print_help_strings(table[j].name, table[j].help, value, FALSE);
}
first = TRUE;
for (j = 0;; j++) {
found = FALSE;
if ((name = index_to_restriction(j)) == 0) {
break;
}
for (k = 0; k < TABLESIZE(table); k++) {
if (!strcmp(name, table[k].name)) {
found = TRUE;
}
}
if (!found) {
if (first) {
printf("Other restrictions (see the user's guide):\n");
}
value = show_restriction(table[j].name);
printf("%s%s (%s)", column ? ", " : " ", name, value);
column += 5 + strlen(name) + strlen(value);
if (column > 50) {
column = 0;
printf("\n");
}
first = FALSE;
}
}
if (column)
printf("\n");
SetOutputMode(O_BINARY);
exit_immediately(EXIT_SUCCESS);
} else if (*next_arg == '?') {
SetOutputMode(O_TEXT);
print_restrictions_to_fd(stdout);
SetOutputMode(O_BINARY);
exit_immediately(EXIT_SUCCESS);
} else {
parse_restrictions(next_arg);
}
return 0;
}
/* -selective */
static int selective_fun(char *next_arg GCC_UNUSED)
{
HTDirAccess = HT_DIR_SELECTIVE;
return 0;
}
/* -source */
static int source_fun(char *next_arg GCC_UNUSED)
{
force_dump_mode();
HTOutputFormat = (LYPrependBase ?
HTAtom_for("www/download") : HTAtom_for("www/dump"));
LYcols = MAX_COLS;
return 0;
}
/* -traversal */
static int traversal_fun(char *next_arg GCC_UNUSED)
{
traversal = TRUE;
#ifdef USE_SLANG
LYcols = DFT_COLS;
#else
LYcols = MAX_COLS;
#endif /* USE_SLANG */
return 0;
}
/* -version */
static int version_fun(char *next_arg GCC_UNUSED)
{
char *result = NULL;
SetLocale();
SetOutputMode(O_TEXT);
HTSprintf0(&result, gettext("%s Version %s (%s)"),
LYNX_NAME, LYNX_VERSION,
LYVersionDate());
StrAllocCat(result, "\n");
#ifdef USE_SSL
HTSprintf(&result, "libwww-FM %s,", HTLibraryVersion);
append_ssl_version(&result, " ");
#else
HTSprintf(&result, "libwww-FM %s", HTLibraryVersion);
#endif /* USE_SSL */
#if defined(NCURSES) && defined(HAVE_CURSES_VERSION)
HTSprintf(&result, ", %s", curses_version());
#if defined(WIDEC_CURSES)
HTSprintf(&result, "(wide)");
#endif
#elif defined(PDCURSES) && defined(PDC_BUILD)
HTSprintf(&result, ", pdcurses %.3f", PDC_BUILD * 0.001);
#elif defined(USE_SLANG) && defined(SLANG_VERSION_STRING)
HTSprintf(&result, ", s-lang %s", SLANG_VERSION_STRING);
#endif
printf("%s\n", result);
free(result);
#ifndef __DATE__
#define __DATE__ ""
#endif
#ifndef __TIME__
#define __TIME__ ""
#endif
/*
* SYSTEM_NAME is set by the configure script. Show build date/time for other
* systems, according to predefined compiler symbols.
*/
#ifdef SYSTEM_NAME
printf(gettext("Built on %s %s %s\n"), SYSTEM_NAME, __DATE__, __TIME__);
#else
#ifdef __CYGWIN__
printf("Compiled by CYGWIN (%s %s).\n", __DATE__, __TIME__);
#else
#ifdef __BORLANDC__
printf("Compiled by Borland C++ (%s %s).\n", __DATE__, __TIME__);
#else
#ifdef _MSC_VER
printf("Compiled by Microsoft Visual C++ (%s %s).\n", __DATE__, __TIME__);
#else
#ifdef __DJGPP__
printf("Compiled by DJGPP (%s %s).\n", __DATE__, __TIME__);
#else
printf("Compiled at (%s %s).\n", __DATE__, __TIME__);
#endif /* __DJGPP__ */
#endif /* _MSC_VER */
#endif /* __BORLANDC__ */
#endif /* __CYGWIN__ */
#endif
puts("");
puts(gettext("Copyrights held by the Lynx Developers Group,"));
puts(gettext("the University of Kansas, CERN, and other contributors."));
puts(gettext("Distributed under the GNU General Public License (Version 2)."));
puts(gettext("See http://lynx.isc.org/ and the online help for more information."));
puts("");
#ifdef USE_SSL
#if defined(OPENSSL_VERSION_TEXT) && !defined(LIBGNUTLS_VERSION)
puts("See http://www.openssl.org/ for information about OpenSSL.");
#endif /* OPENSSL_VERSION_TEXT */
puts("");
#endif /* USE_SSL */
SetOutputMode(O_BINARY);
exit_immediately(EXIT_SUCCESS);
/* NOT REACHED */
return 0;
}
/* -width */
static int width_fun(char *next_arg)
{
if (next_arg != 0) {
int w = atoi(next_arg);
if (w > 0)
dump_output_width = ((w < MAX_COLS) ? w : MAX_COLS);
}
return 0;
}
#if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
/* -scrsize */
static int scrsize_fun(char *next_arg)
{
if (next_arg != 0) {
char *cp;
if ((cp = strchr(next_arg, ',')) != 0) {
*cp++ = '\0'; /* Terminate ID */
scrsize_x = atoi(next_arg);
scrsize_y = atoi(cp);
if ((scrsize_x <= 1) || (scrsize_y <= 1)) {
scrsize_x = scrsize_y = 0;
}
if ((scrsize_x > 0) && (scrsize_x < 80)) {
scrsize_x = 80;
}
if ((scrsize_y > 0) && (scrsize_y < 4)) {
scrsize_y = 4;
}
CTRACE((tfp, "scrsize: x=%d, y=%d\n", scrsize_x, scrsize_y));
}
}
return 0;
}
#endif
/* NOTE: This table is sorted by name to make the help message useful */
/* *INDENT-OFF* */
static Config_Type Arg_Table [] =
{
PARSE_SET(
"accept_all_cookies", 4|SET_ARG, LYAcceptAllCookies,
"\naccept cookies without prompting if Set-Cookie handling\nis on"
),
PARSE_FUN(
"anonymous", 2|FUNCTION_ARG, anonymous_fun,
"apply restrictions for anonymous account,\nsee also -restrictions"
),
PARSE_FUN(
"assume_charset", 4|NEED_FUNCTION_ARG, assume_charset_fun,
"=MIMEname\ncharset for documents that don't specify it"
),
PARSE_FUN(
"assume_local_charset", 4|NEED_FUNCTION_ARG, assume_local_charset_fun,
"=MIMEname\ncharset assumed for local files"
),
PARSE_FUN(
"assume_unrec_charset", 4|NEED_FUNCTION_ARG, assume_unrec_charset_fun,
"=MIMEname\nuse this instead of unrecognized charsets"
),
PARSE_FUN(
"auth", 4|NEED_FUNCTION_ARG, auth_fun,
"=id:pw\nauthentication information for protected documents"
),
PARSE_FUN(
"base", 4|FUNCTION_ARG, base_fun,
"prepend a request URL comment and BASE tag to text/html\n\
outputs for -source dumps"
),
#ifndef DISABLE_BIBP
PARSE_STR(
"bibhost", 4|NEED_LYSTRING_ARG, BibP_bibhost,
"=URL\nlocal bibp server (default http://bibhost/)"
),
#endif
#ifdef USE_BLINK
PARSE_SET(
"blink", 4|SET_ARG, term_blink_is_boldbg,
"enable bright background via the BLINK terminal attribute"
),
#endif
PARSE_SET(
"book", 4|SET_ARG, bookmark_start,
"use the bookmark page as the startfile"
),
PARSE_SET(
"buried_news", 4|TOGGLE_ARG, scan_for_buried_news_references,
"toggles scanning of news articles for buried references"
),
PARSE_FUN(
"cache", 4|NEED_FUNCTION_ARG, cache_fun,
"=NUMBER\nNUMBER of documents cached in memory"
),
PARSE_SET(
"case", 4|SET_ARG, case_sensitive,
"enable case sensitive user searching"
),
PARSE_SET(
"center", 4|TOGGLE_ARG, no_table_center,
"toggle center alignment in HTML TABLE"
),
PARSE_STR(
"cfg", 2|NEED_LYSTRING_ARG, lynx_cfg_file,
"=FILENAME\nspecifies a lynx.cfg file other than the default"
),
PARSE_FUN(
"child", 4|FUNCTION_ARG, child_fun,
"exit on left-arrow in startfile, and disable save to disk"
),
PARSE_FUN(
"child_relaxed", 4|FUNCTION_ARG, child_relaxed_fun,
"exit on left-arrow in startfile (allows save to disk)"
),
#ifdef USE_CMD_LOGGING
PARSE_STR(
"cmd_log", 2|NEED_LYSTRING_ARG, lynx_cmd_logfile,
"=FILENAME\nlog keystroke commands to the given file"
),
PARSE_STR(
"cmd_script", 2|NEED_LYSTRING_ARG, lynx_cmd_script,
"=FILENAME\nread keystroke commands from the given file\n(see -cmd_log)"
),
#endif
#ifdef USE_SLANG
PARSE_FUN(
"color", 4|FUNCTION_ARG, color_fun,
"force color mode on with standard bg colors"
),
#endif
PARSE_INT(
"connect_timeout", 4|NEED_INT_ARG, connect_timeout,
"=N\nset the N-second connection timeout"
),
#ifdef MISC_EXP
PARSE_FUN(
"convert_to", 4|FUNCTION_ARG, convert_to_fun,
"=FORMAT\nconvert input, FORMAT is in MIME type notation\n(experimental)"
),
#endif
#ifdef USE_PERSISTENT_COOKIES
PARSE_STR(
"cookie_file", 4|LYSTRING_ARG, LYCookieFile,
"=FILENAME\nspecifies a file to use to read cookies"
),
PARSE_STR(
"cookie_save_file", 4|LYSTRING_ARG, LYCookieSaveFile,
"=FILENAME\nspecifies a file to use to store cookies"
),
#endif /* USE_PERSISTENT_COOKIES */
PARSE_SET(
"cookies", 4|TOGGLE_ARG, LYSetCookies,
"toggles handling of Set-Cookie headers"
),
#ifndef VMS
PARSE_SET(
"core", 4|TOGGLE_ARG, LYNoCore,
"toggles forced core dumps on fatal errors"
),
#endif
PARSE_FUN(
"crawl", 4|FUNCTION_ARG, crawl_fun,
"with -traversal, output each page to a file\n\
with -dump, format output as with -traversal, but to stdout"
),
#ifdef USE_CURSES_PADS
PARSE_SET(
"curses_pads", 4|TOGGLE_ARG, LYuseCursesPads,
"uses curses pad feature to support left/right shifting"
),
#endif
#ifdef DISP_PARTIAL
PARSE_SET(
"debug_partial", 4|TOGGLE_ARG, debug_display_partial,
"incremental display stages with MessageSecs delay"
),
#endif
PARSE_INT(
"delay", 4|NEED_TIME_ARG, DebugSecs,
"=NNN\nset NNN-second delay at statusline message"
),
PARSE_FUN(
"display", 4|NEED_FUNCTION_ARG, display_fun,
"=DISPLAY\nset the display variable for X exec'ed programs"
),
PARSE_FUN(
"display_charset", 4|NEED_FUNCTION_ARG, display_charset_fun,
"=MIMEname\ncharset for the terminal output"
),
PARSE_SET(
"dont_wrap_pre", 4|SET_ARG, dont_wrap_pre,
"inhibit wrapping of text in <pre> when -dump'ing and\n\
-crawl'ing, mark wrapped lines in interactive session"
),
PARSE_FUN(
"dump", 4|FUNCTION_ARG, dump_output_fun,
"dump the first file to stdout and exit"
),
PARSE_FUN(
"editor", 4|NEED_FUNCTION_ARG, editor_fun,
"=EDITOR\nenable edit mode with specified editor"
),
PARSE_SET(
"emacskeys", 4|SET_ARG, emacs_keys,
"enable emacs-like key movement"
),
PARSE_SET(
"enable_scrollback", 4|TOGGLE_ARG, enable_scrollback,
"\ntoggles compatibility with comm programs' scrollback\n\
keys (may be incompatible with some curses packages)"
),
PARSE_FUN(
"error_file", 4|NEED_FUNCTION_ARG, error_file_fun,
"=FILE\nwrite the HTTP status code here"
),
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
#ifndef NEVER_ALLOW_REMOTE_EXEC
PARSE_FUN(
"exec", 4|FUNCTION_ARG, exec_fun,
"enable local program execution"
),
#endif
#endif /* EXEC_LINKS || EXEC_SCRIPTS */
#ifdef VMS
PARSE_SET(
"fileversions", 4|SET_ARG, HTVMSFileVersions,
"include all versions of files in local VMS directory\nlistings"
),
#endif
#ifdef LY_FIND_LEAKS
PARSE_SET(
"find_leaks", 4|TOGGLE_ARG, LYfind_leaks,
"toggles memory-leak checking"
),
#endif
PARSE_SET(
"force_empty_hrefless_a", 4|SET_ARG, force_empty_hrefless_a,
"\nforce HREF-less 'A' elements to be empty (close them as\n\
soon as they are seen)"
),
PARSE_SET(
"force_html", 4|SET_ARG, LYforce_HTML_mode,
"forces the first document to be interpreted as HTML"
),
PARSE_SET(
"force_secure", 4|TOGGLE_ARG, LYForceSSLCookiesSecure,
"toggles forcing of the secure flag for SSL cookies"
),
#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU)
PARSE_SET(
"forms_options", 4|TOGGLE_ARG, LYUseFormsOptions,
"toggles forms-based vs old-style options menu"
),
#endif
PARSE_SET(
"from", 4|TOGGLE_ARG, LYNoFromHeader,
"toggle transmission of From headers"
),
#ifndef DISABLE_FTP
PARSE_SET(
"ftp", 4|UNSET_ARG, ftp_ok,
"disable ftp access"
),
#endif
PARSE_FUN(
"get_data", 2|FUNCTION_ARG, get_data_fun,
"user data for get forms, read from stdin,\nterminated by '---' on a line"
),
PARSE_SET(
"head", 4|SET_ARG, HEAD_request,
"send a HEAD request"
),
PARSE_FUN(
"help", 4|FUNCTION_ARG, help_fun,
"print this usage message"
),
PARSE_FUN(
"hiddenlinks", 4|NEED_FUNCTION_ARG, hiddenlinks_fun,
"=[option]\nhidden links: options are merge, listonly, or ignore"
),
PARSE_SET(
"historical", 4|TOGGLE_ARG, historical_comments,
"toggles use of '>' or '-->' as terminator for comments"
),
PARSE_FUN(
"homepage", 4|NEED_FUNCTION_ARG, homepage_fun,
"=URL\nset homepage separate from start page"
),
PARSE_SET(
"image_links", 4|TOGGLE_ARG, clickable_images,
"toggles inclusion of links for all images"
),
PARSE_STR(
"index", 4|NEED_LYSTRING_ARG, indexfile,
"=URL\nset the default index file to URL"
),
PARSE_SET(
"ismap", 4|TOGGLE_ARG, LYNoISMAPifUSEMAP,
"toggles inclusion of ISMAP links when client-side\nMAPs are present"
),
#ifdef USE_JUSTIFY_ELTS
PARSE_SET(
"justify", 4|SET_ARG, ok_justify,
"do justification of text"
),
#endif
PARSE_INT(
"link", 4|NEED_INT_ARG, crawl_count,
"=NUMBER\nstarting count for lnk#.dat files produced by -crawl"
),
PARSE_SET(
"listonly", 4|TOGGLE_ARG, dump_links_only,
"with -dump, forces it to show only the list of links"
),
PARSE_SET(
"localhost", 4|SET_ARG, local_host_only,
"disable URLs that point to remote hosts"
),
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
PARSE_SET(
"locexec", 4|SET_ARG, local_exec_on_local_files,
"enable local program execution from local files only"
),
#endif /* EXEC_LINKS || EXEC_SCRIPTS */
#if defined(USE_COLOR_STYLE)
PARSE_STR(
"lss", 2|NEED_LYSTRING_ARG, lynx_lss_file2,
"=FILENAME\nspecifies a lynx.lss file other than the default"
),
#endif
PARSE_FUN(
"mime_header", 4|FUNCTION_ARG, mime_header_fun,
"include mime headers and force source dump"
),
PARSE_SET(
"minimal", 4|TOGGLE_ARG, minimal_comments,
"toggles minimal versus valid comment parsing"
),
#ifdef EXP_NESTED_TABLES
PARSE_SET(
"nested_tables", 4|TOGGLE_ARG, nested_tables,
"toggles nested-tables logic"
),
#endif
#ifndef DISABLE_NEWS
PARSE_FUN(
"newschunksize", 4|NEED_FUNCTION_ARG, newschunksize_fun,
"=NUMBER\nnumber of articles in chunked news listings"
),
PARSE_FUN(
"newsmaxchunk", 4|NEED_FUNCTION_ARG, newsmaxchunk_fun,
"=NUMBER\nmaximum news articles in listings before chunking"
),
#endif
#if USE_BLAT_MAILER
PARSE_SET(
"noblat", 4|TOGGLE_ARG, mail_is_blat,
"select mail tool (`BLAT' ==> `sendmail')"
),
#endif
PARSE_FUN(
"nobold", 4|FUNCTION_ARG, nobold_fun,
"disable bold video-attribute"
),
PARSE_FUN(
"nobrowse", 4|FUNCTION_ARG, nobrowse_fun,
"disable directory browsing"
),
PARSE_SET(
"nocc", 4|SET_ARG, LYNoCc,
"disable Cc: prompts for self copies of mailings"
),
PARSE_FUN(
"nocolor", 4|FUNCTION_ARG, nocolor_fun,
"turn off color support"
),
#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
PARSE_SET(
"noexec", 4|UNSET_ARG, local_exec,
"disable local program execution (DEFAULT)"
),
#endif /* EXEC_LINKS || EXEC_SCRIPTS */
PARSE_SET(
"nofilereferer", 4|SET_ARG, no_filereferer,
"disable transmission of Referer headers for file URLs"
),
PARSE_SET(
"nolist", 4|SET_ARG, no_list,
"disable the link list feature in dumps"
),
PARSE_SET(
"nolog", 4|UNSET_ARG, error_logging,
"disable mailing of error messages to document owners"
),
PARSE_SET(
"nomargins", 4|SET_ARG, no_margins,
"disable the right/left margins in the default\nstyle-sheet"
),
PARSE_FUN(
"nomore", 4|FUNCTION_ARG, nomore_fun,
"disable -more- string in statusline messages"
),
#if defined(HAVE_SIGACTION) && defined(SIGWINCH)
PARSE_SET(
"nonrestarting_sigwinch", 4|SET_ARG, LYNonRestartingSIGWINCH,
"\nmake window size change handler non-restarting"
),
#endif /* HAVE_SIGACTION */
PARSE_SET(
"nonumbers", 4|SET_ARG, no_numbers,
"disable the link/form numbering feature in dumps"
),
PARSE_FUN(
"nopause", 4|FUNCTION_ARG, nopause_fun,
"disable forced pauses for statusline messages"
),
PARSE_SET(
"noprint", 4|SET_ARG, no_print,
"disable some print functions, like -restrictions=print"
),
PARSE_SET(
"noredir", 4|SET_ARG, no_url_redirection,
"don't follow Location: redirection"
),
PARSE_SET(
"noreferer", 4|SET_ARG, LYNoRefererHeader,
"disable transmission of Referer headers"
),
PARSE_FUN(
"noreverse", 4|FUNCTION_ARG, noreverse_fun,
"disable reverse video-attribute"
),
#ifdef SOCKS
PARSE_SET(
"nosocks", 2|UNSET_ARG, socks_flag,
"don't use SOCKS proxy for this session"
),
#endif
PARSE_SET(
"nostatus", 4|SET_ARG, no_statusline,
"disable the miscellaneous information messages"
),
PARSE_SET(
"notitle", 4|SET_ARG, no_title,
"disable the title at the top of each page"
),
PARSE_FUN(
"nounderline", 4|FUNCTION_ARG, nounderline_fun,
"disable underline video-attribute"
),
#ifdef MISC_EXP
PARSE_FUN(
"nozap", 4|FUNCTION_ARG, nozap_fun,
"=DURATION (\"initially\" or \"full\") disable checks for 'z' key"
),
#endif
PARSE_SET(
"number_fields", 4|SET_ARG, number_fields,
"force numbering of links as well as form input fields"
),
PARSE_SET(
"number_links", 4|SET_ARG, number_links,
"force numbering of links"
),
#ifdef DISP_PARTIAL
PARSE_SET(
"partial", 4|TOGGLE_ARG, display_partial_flag,
"toggles display partial pages while downloading"
),
PARSE_INT(
"partial_thres", 4|NEED_INT_ARG, partial_threshold,
"[=NUMBER]\nnumber of lines to render before repainting display\n\
with partial-display logic"
),
#endif
#ifndef DISABLE_FTP
PARSE_SET(
"passive-ftp", 4|TOGGLE_ARG, ftp_passive,
"toggles passive ftp connection"
),
#endif
PARSE_FUN(
"pauth", 4|NEED_FUNCTION_ARG, pauth_fun,
"=id:pw\nauthentication information for protected proxy server"
),
PARSE_SET(
"popup", 4|UNSET_ARG, LYUseDefSelPop,
"toggles handling of single-choice SELECT options via\n\
popup windows or as lists of radio buttons"
),
PARSE_FUN(
"post_data", 2|FUNCTION_ARG, post_data_fun,
"user data for post forms, read from stdin,\n\
terminated by '---' on a line"
),
PARSE_SET(
"preparsed", 4|SET_ARG, LYPreparsedSource,
"show parsed text/html with -source and in source view\n\
to visualize how lynx behaves with invalid HTML"
),
#ifdef USE_PRETTYSRC
PARSE_SET(
"prettysrc", 4|SET_ARG, LYpsrc,
"do syntax highlighting and hyperlink handling in source\nview"
),
#endif
PARSE_SET(
"print", 4|UNSET_ARG, no_print,
"enable print functions (DEFAULT), opposite of -noprint"
),
PARSE_SET(
"pseudo_inlines", 4|TOGGLE_ARG, pseudo_inline_alts,
"toggles pseudo-ALTs for inlines with no ALT string"
),
PARSE_SET(
"raw", 4|UNSET_ARG, LYUseDefaultRawMode,
"toggles default setting of 8-bit character translations\n\
or CJK mode for the startup character set"
),
PARSE_SET(
"realm", 4|SET_ARG, check_realm,
"restricts access to URLs in the starting realm"
),
PARSE_INT(
"read_timeout", 4|NEED_INT_ARG, reading_timeout,
"=N\nset the N-second read-timeout"
),
PARSE_SET(
"reload", 4|SET_ARG, reloading,
"flushes the cache on a proxy server\n(only the first document affected)"
),
PARSE_FUN(
"restrictions", 4|FUNCTION_ARG, restrictions_fun,
"=[options]\nuse -restrictions to see list"
),
PARSE_SET(
"resubmit_posts", 4|TOGGLE_ARG, LYresubmit_posts,
"toggles forced resubmissions (no-cache) of forms with\n\
method POST when the documents they returned are sought\n\
with the PREV_DOC command or from the History List"
),
PARSE_SET(
"rlogin", 4|UNSET_ARG, rlogin_ok,
"disable rlogins"
),
#if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
PARSE_FUN(
"scrsize", 4|NEED_FUNCTION_ARG, scrsize_fun,
"=width,height\nsize of window"
),
#endif
#ifdef USE_SCROLLBAR
PARSE_SET(
"scrollbar", 4|TOGGLE_ARG, LYShowScrollbar,
"toggles showing scrollbar"
),
PARSE_SET(
"scrollbar_arrow", 4|TOGGLE_ARG, LYsb_arrow,
"toggles showing arrows at ends of the scrollbar"
),
#endif
PARSE_FUN(
"selective", 4|FUNCTION_ARG, selective_fun,
"require .www_browsable files to browse directories"
),
#ifdef USE_SESSIONS
PARSE_STR(
"session", 2|NEED_LYSTRING_ARG, session_file,
"=FILENAME\nresumes from specified file on startup and\n\
saves session to that file on exit"
),
PARSE_STR(
"sessionin", 2|NEED_LYSTRING_ARG, sessionin_file,
"=FILENAME\nresumes session from specified file"
),
PARSE_STR(
"sessionout", 2|NEED_LYSTRING_ARG, sessionout_file,
"=FILENAME\nsaves session to specified file"
),
#endif /* USE_SESSIONS */
PARSE_SET(
"short_url", 4|SET_ARG, long_url_ok,
"enables examination of beginning and end of long URL in\nstatus line"
),
PARSE_SET(
"show_cfg", 1|SET_ARG, show_cfg,
"Show `LYNX.CFG' setting"
),
PARSE_SET(
"show_cursor", 4|TOGGLE_ARG, LYUseDefShoCur,
"toggles hiding of the cursor in the lower right corner"
),
#ifdef USE_READPROGRESS
PARSE_SET(
"show_rate", 4|TOGGLE_ARG, LYShowTransferRate,
"toggles display of transfer rate"
),
#endif
PARSE_SET(
"soft_dquotes", 4|TOGGLE_ARG, soft_dquotes,
"toggles emulation of the old Netscape and Mosaic\n\
bug which treated '>' as a co-terminator for\ndouble-quotes and tags"
),
PARSE_FUN(
"source", 4|FUNCTION_ARG, source_fun,
"dump the source of the first file to stdout and exit"
),
PARSE_SET(
"stack_dump", 4|SET_ARG, stack_dump,
"disable SIGINT cleanup handler"
),
PARSE_SET(
"startfile_ok", 4|SET_ARG, startfile_ok,
"allow non-http startfile and homepage with -validate"
),
PARSE_SET(
"stderr", 4|SET_ARG, dump_to_stderr,
"write warning messages to standard error when -dump\nor -source is used"
),
PARSE_SET(
"stdin", 4|SET_ARG, startfile_stdin,
"read startfile from standard input"
),
#ifdef SYSLOG_REQUESTED_URLS
PARSE_STR(
"syslog", 4|NEED_LYSTRING_ARG, syslog_txt,
"=text\ninformation for syslog call"
),
PARSE_SET(
"syslog-urls", 4|SET_ARG, syslog_requested_urls,
"log requested URLs with syslog"
),
#endif
PARSE_SET(
"tagsoup", 4|SET_ARG, DTD_recovery,
"use TagSoup rather than SortaSGML parser"
),
PARSE_SET(
"telnet", 4|UNSET_ARG, telnet_ok,
"disable telnets"
),
PARSE_STR(
"term", 4|NEED_STRING_ARG, terminal,
"=TERM\nset terminal type to TERM"
),
#ifdef _WINDOWS
PARSE_INT(
"timeout", 4|INT_ARG, lynx_timeout,
"=NUMBER\nset TCP/IP timeout"
),
#endif
PARSE_SET(
"tlog", 2|TOGGLE_ARG, LYUseTraceLog,
"toggles use of a Lynx Trace Log for the current\nsession"
),
#ifdef TEXTFIELDS_MAY_NEED_ACTIVATION
PARSE_SET(
"tna", 4|SET_ARG, textfields_activation_option,
"turn on \"Textfields Need Activation\" mode"
),
#endif
#ifndef NO_LYNX_TRACE
PARSE_SET(
"trace", 1|SET_ARG, WWW_TraceFlag,
"turns on Lynx trace mode"
),
PARSE_INT(
"trace_mask", 1|INT_ARG, WWW_TraceMask,
"customize Lynx trace mode"
),
#endif
PARSE_FUN(
"traversal", 4|FUNCTION_ARG, traversal_fun,
"traverse all http links derived from startfile"
),
PARSE_SET(
"trim_input_fields", 2|SET_ARG, LYtrimInputFields,
"\ntrim input text/textarea fields in forms"
),
PARSE_SET(
"underline_links",4|TOGGLE_ARG, LYUnderlineLinks,
"toggles use of underline/bold attribute for links"
),
PARSE_SET(
"underscore", 4|TOGGLE_ARG, use_underscore,
"toggles use of _underline_ format in dumps"
),
#if defined(USE_MOUSE)
PARSE_SET(
"use_mouse", 4|SET_ARG, LYUseMouse,
"turn on mouse support"
),
#endif
PARSE_STR(
"useragent", 4|NEED_LYSTRING_ARG, LYUserAgent,
"=Name\nset alternate Lynx User-Agent header"
),
PARSE_SET(
"validate", 2|SET_ARG, LYValidate,
"accept only http URLs (meant for validation)\n\
implies more restrictions than -anonymous, but\n\
goto is allowed for http and https"
),
PARSE_SET(
"verbose", 4|TOGGLE_ARG, verbose_img,
"toggles [LINK], [IMAGE] and [INLINE] comments\n\
with filenames of these images"
),
PARSE_FUN(
"version", 1|FUNCTION_ARG, version_fun,
"print Lynx version information"
),
PARSE_SET(
"vikeys", 4|SET_ARG, vi_keys,
"enable vi-like key movement"
),
#ifdef __DJGPP__
PARSE_SET(
"wdebug", 4|TOGGLE_ARG, watt_debug,
"enables Waterloo tcp/ip packet debug. Prints to watt\ndebugfile"
),
#endif /* __DJGPP__ */
PARSE_FUN(
"width", 4|NEED_FUNCTION_ARG, width_fun,
"=NUMBER\nscreen width for formatting of dumps (default is 80)"
),
#ifndef NO_DUMP_WITH_BACKSPACES
PARSE_SET(
"with_backspaces", 4|SET_ARG, with_backspaces,
"emit backspaces in output if -dumping or -crawling\n(like 'man' does)"
),
#endif
PARSE_SET(
"xhtml-parsing", 4|SET_ARG, LYxhtml_parsing,
"enable XHTML 1.0 parsing"
),
PARSE_NIL
};
/* *INDENT-ON* */
static void print_help_strings(const char *name,
const char *help,
const char *value,
BOOLEAN option)
{
int pad;
int c;
int first;
int field_width = 20;
pad = field_width - (2 + option + (int) strlen(name));
fprintf(stdout, " %s%s", option ? "-" : "", name);
if (*help != '=') {
pad--;
while (pad > 0) {
fputc(' ', stdout);
pad--;
}
fputc(' ', stdout); /* at least one space */
first = 0;
} else {
first = pad;
}
if (strchr(help, '\n') == 0) {
fprintf(stdout, "%s", help);
} else {
while ((c = *help) != 0) {
if (c == '\n') {
if ((pad = --first) < 0) {
pad = field_width;
} else {
c = ' ';
}
fputc(c, stdout);
while (pad--)
fputc(' ', stdout);
} else {
fputc(c, stdout);
}
help++;
first--;
}
}
if (value)
printf(" (%s)", value);
fputc('\n', stdout);
}
static void print_help_and_exit(int exit_status)
{
Config_Type *p;
if (pgm == NULL)
pgm = "lynx";
SetOutputMode(O_TEXT);
fprintf(stdout, gettext("USAGE: %s [options] [file]\n"), pgm);
fprintf(stdout, gettext("Options are:\n"));
#ifdef VMS
print_help_strings("",
"receive the arguments from stdin (enclose\n\
in double-quotes (\"-\") on VMS)", NULL, TRUE);
#else
print_help_strings("", "receive options and arguments from stdin", NULL, TRUE);
#endif /* VMS */
for (p = Arg_Table; p->name != 0; p++) {
char temp[LINESIZE], *value = temp;
ParseUnionPtr q = ParseUnionOf(p);
switch (p->type & ARG_TYPE_MASK) {
case TOGGLE_ARG:
case SET_ARG:
strcpy(temp, *(q->set_value) ? "on" : "off");
break;
case UNSET_ARG:
strcpy(temp, *(q->set_value) ? "off" : "on");
break;
case INT_ARG:
sprintf(temp, "%d", *(q->int_value));
break;
case TIME_ARG:
sprintf(temp, SECS_FMT, (double) Secs2SECS(*(q->int_value)));
break;
case STRING_ARG:
if ((value = *(q->str_value)) != 0
&& !*value)
value = 0;
break;
default:
value = 0;
break;
}
print_help_strings(p->name, p->help_string, value, TRUE);
}
SetOutputMode(O_BINARY);
exit_immediately(exit_status);
}
/*
* This function performs a string comparison on two strings a and b. a is
* assumed to be an ordinary null terminated string, but b may be terminated
* by an '=', '+' or '-' character. If terminated by '=', *c will be pointed
* to the character following the '='. If terminated by '+' or '-', *c will
* be pointed to that character. (+/- added for toggle processing - BL.)
* If a and b match, it returns 1. Otherwise 0 is returned.
*/
static int arg_eqs_parse(const char *a,
char *b,
char **c)
{
int result = -1;
*c = NULL;
while (result < 0) {
if ((*a != *b)
|| (*a == 0)
|| (*b == 0)) {
if (*a == 0) {
switch (*b) {
case '\t': /* embedded blank when reading stdin */
case ' ':
*c = LYSkipBlanks(b);
result = 1;
break;
case '=':
case ':':
*c = b + 1;
result = 1;
break;
case '-':
#if OPTNAME_ALLOW_DASHES
if (isalpha(UCH(b[1]))) {
result = 0;
break;
}
#endif
/* FALLTHRU */
case '+':
*c = b;
result = 1;
break;
case 0:
result = 1;
break;
default:
result = 0;
break;
}
} else {
#if OPTNAME_ALLOW_DASHES
if (!(*a == '_' && *b == '-'))
#endif
result = 0;
}
}
a++;
b++;
}
return result;
}
#define is_true(s) (*s == '1' || *s == '+' || !strcasecomp(s, "on") || !strcasecomp(s, "true"))
#define is_false(s) (*s == '0' || *s == '-' || !strcasecomp(s, "off") || !strcasecomp(s, "false"))
/*
* Parse an option.
* argv[] points to the beginning of the unprocessed options.
* mask is used to select certain options which must be processed
* before others.
* countp (if nonnull) points to an index into argv[], which is updated
* to reflect option values which are also parsed.
*/
static BOOL parse_arg(char **argv,
unsigned mask,
int *countp)
{
Config_Type *p;
char *arg_name;
#if EXTENDED_STARTFILE_RECALL
static BOOLEAN no_options_further = FALSE; /* set to TRUE after '--' argument */
static int nof_index = 0; /* set the index of -- argument */
#endif
arg_name = argv[0];
CTRACE((tfp, "parse_arg(arg_name=%s, mask=%u, count=%d)\n",
arg_name, mask, countp ? *countp : -1));
#if EXTENDED_STARTFILE_RECALL
if (mask == (unsigned) ((countp != 0) ? 0 : 1)) {
no_options_further = FALSE;
/* want to reset nonoption when beginning scan for --stdin */
if (nonoption != 0) {
FREE(nonoption);
}
}
#endif
/*
* Check for a command line startfile. - FM
*/
if (*arg_name != '-'
#if EXTENDED_OPTION_LOGIC
|| (no_options_further == TRUE && nof_index < (*countp))
#endif
) {
#if EXTENDED_STARTFILE_RECALL
/*
* On the last pass (mask==4), check for cases where we may want to
* provide G)oto history for multiple startfiles.
*/
if (mask == 4) {
if (nonoption != 0) {
LYEnsureAbsoluteURL(&nonoption, "NONOPTION", FALSE);
HTAddGotoURL(nonoption);
FREE(nonoption);
}
StrAllocCopy(nonoption, arg_name);
}
#endif
StrAllocCopy(startfile, arg_name);
LYEscapeStartfile(&startfile);
#ifdef _WINDOWS /* 1998/01/14 (Wed) 20:11:17 */
HTUnEscape(startfile);
{
char *q = startfile;
while (*q++) {
if (*q == '|')
*q = ':';
}
}
#endif
CTRACE((tfp, "parse_arg startfile:%s\n", startfile));
return (BOOL) (countp != 0);
}
#if EXTENDED_OPTION_LOGIC
if (strcmp(arg_name, "--") == 0) {
no_options_further = TRUE;
nof_index = *countp;
return TRUE;
}
#endif
/* lose the first '-' character */
arg_name++;
/*
* Skip any lone "-" arguments, because we've loaded the stdin input into
* an HTList structure for special handling. - FM
*/
if (*arg_name == 0)
return TRUE;
/* allow GNU-style options with -- prefix */
if (*arg_name == '-')
++arg_name;
CTRACE((tfp, "parse_arg lookup(%s)\n", arg_name));
p = Arg_Table;
while (p->name != 0) {
ParseUnionPtr q = ParseUnionOf(p);
ParseFunc fun;
char *next_arg = NULL;
char *temp_ptr = NULL;
if ((p->name[0] != *arg_name)
|| (0 == arg_eqs_parse(p->name, arg_name, &next_arg))) {
p++;
continue;
}
if (p->type & NEED_NEXT_ARG) {
if (next_arg == 0) {
next_arg = argv[1];
if ((countp != 0) && (next_arg != 0))
(*countp)++;
}
CTRACE((tfp, "...arg:%s\n", NONNULL(next_arg)));
}
/* ignore option if it's not our turn */
if ((p->type & mask) == 0) {
CTRACE((tfp, "...skip (mask %u/%d)\n", mask, p->type & 7));
return FALSE;
}
switch (p->type & ARG_TYPE_MASK) {
case TOGGLE_ARG: /* FALLTHRU */
case SET_ARG: /* FALLTHRU */
case UNSET_ARG:
if (q->set_value != 0) {
if (next_arg == 0) {
switch (p->type & ARG_TYPE_MASK) {
case TOGGLE_ARG:
*(q->set_value) = (BOOL) !(*(q->set_value));
break;
case SET_ARG:
*(q->set_value) = TRUE;
break;
case UNSET_ARG:
*(q->set_value) = FALSE;
break;
}
} else if (is_true(next_arg)) {
*(q->set_value) = TRUE;
} else if (is_false(next_arg)) {
*(q->set_value) = FALSE;
}
/* deliberately ignore anything else - BL */
}
break;
case FUNCTION_ARG:
fun = q->fun_value;
if (0 != fun) {
if (-1 == (*fun) (next_arg)) {
}
}
break;
case LYSTRING_ARG:
if ((q->str_value != 0) && (next_arg != 0))
StrAllocCopy(*(q->str_value), next_arg);
break;
case INT_ARG:
if ((q->int_value != 0) && (next_arg != 0))
*(q->int_value) = strtol(next_arg, &temp_ptr, 0);
break;
case TIME_ARG:
if ((q->int_value != 0) && (next_arg != 0)) {
float ival;
if (1 == LYscanFloat(next_arg, &ival)) {
*(q->int_value) = (int) SECS2Secs(ival);
}
}
break;
case STRING_ARG:
if ((q->str_value != 0) && (next_arg != 0))
*(q->str_value) = next_arg;
break;
}
Old_DTD = DTD_recovery; /* BOOL != int */
return TRUE;
}
if (pgm == 0)
pgm = "LYNX";
fprintf(stderr, gettext("%s: Invalid Option: %s\n"), pgm, argv[0]);
print_help_and_exit(-1);
return FALSE;
}
#ifndef VMS
static void FatalProblem(int sig)
{
/*
* Ignore further interrupts. - mhc: 11/2/91
*/
#ifndef NOSIGHUP
(void) signal(SIGHUP, SIG_IGN);
#endif /* NOSIGHUP */
(void) signal(SIGTERM, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
#ifndef __linux__
#ifdef SIGBUS
(void) signal(SIGBUS, SIG_IGN);
#endif /* ! SIGBUS */
#endif /* !__linux__ */
(void) signal(SIGSEGV, SIG_IGN);
(void) signal(SIGILL, SIG_IGN);
/*
* Flush all messages. - FM
*/
fflush(stderr);
fflush(stdout);
/*
* Deal with curses, if on, and clean up. - FM
*/
if (LYOutOfMemory && LYCursesON) {
LYSleepAlert();
}
cleanup_sig(0);
#ifndef __linux__
#ifdef SIGBUS
signal(SIGBUS, SIG_DFL);
#endif /* SIGBUS */
#endif /* !__linux__ */
signal(SIGSEGV, SIG_DFL);
signal(SIGILL, SIG_DFL);
/*
* Issue appropriate messages and abort or exit. - FM
*/
if (LYOutOfMemory == FALSE) {
fprintf(stderr, "\r\n\
A Fatal error has occurred in %s Ver. %s\r\n", LYNX_NAME, LYNX_VERSION);
fprintf(stderr, "\r\n\
Please notify your system administrator to confirm a bug, and\r\n\
if confirmed, to notify the lynx-dev list. Bug reports should\r\n\
have concise descriptions of the command and/or URL which causes\r\n\
the problem, the operating system name with version number, the\r\n\
TCPIP implementation, and any other relevant information.\r\n");
if (!(sig == 0 && LYNoCore)) {
fprintf(stderr, "\r\n\
Do NOT mail the core file if one was generated.\r\n");
}
if (sig != 0) {
fprintf(stderr, "\r\n\
Lynx now exiting with signal: %d\r\n\r\n", sig);
#ifdef WIN_EX /* 1998/08/09 (Sun) 09:58:25 */
{
char *msg;
switch (sig) {
case SIGABRT:
msg = "SIGABRT";
break;
case SIGFPE:
msg = "SIGFPE";
break;
case SIGILL:
msg = "SIGILL";
break;
case SIGSEGV:
msg = "SIGSEGV";
break;
default:
msg = "Not-def";
break;
}
fprintf(stderr, "signal code = %s\n", msg);
}
#endif
}
/*
* Exit and possibly dump core.
*/
if (LYNoCore) {
exit_immediately(EXIT_FAILURE);
}
abort();
} else {
LYOutOfMemory = FALSE;
printf("\r\n%s\r\n\r\n", MEMORY_EXHAUSTED_ABORT);
fflush(stdout);
/*
* Exit without dumping core.
*/
exit_immediately(EXIT_FAILURE);
}
}
#endif /* !VMS */
|