File: externs.h

package info (click to toggle)
lout 3.38-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,420 kB
  • ctags: 3,428
  • sloc: ansic: 34,006; makefile: 264; awk: 111; sh: 5
file content (3747 lines) | stat: -rw-r--r-- 200,234 bytes parent folder | download
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
/*@externs.h:External Declarations:Directories and file conventions@**********/
/*                                                                           */
/*  THE LOUT DOCUMENT FORMATTING SYSTEM (VERSION 3.38)                       */
/*  COPYRIGHT (C) 1991, 2008 Jeffrey H. Kingston                             */
/*                                                                           */
/*  Jeffrey H. Kingston (jeff@it.usyd.edu.au)                                */
/*  School of Information Technologies                                       */
/*  The University of Sydney 2006                                            */
/*  AUSTRALIA                                                                */
/*                                                                           */
/*  This program is free software; you can redistribute it and/or modify     */
/*  it under the terms of the GNU General Public License as published by     */
/*  the Free Software Foundation; either Version 3, or (at your option)      */
/*  any later version.                                                       */
/*                                                                           */
/*  This program is distributed in the hope that it will be useful,          */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of           */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            */
/*  GNU General Public License for more details.                             */
/*                                                                           */
/*  You should have received a copy of the GNU General Public License        */
/*  along with this program; if not, write to the Free Software              */
/*  Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA   */
/*                                                                           */
/*  FILE:         externs.h                                                  */
/*  MODULE:       External Declarations                                      */
/*                                                                           */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <locale.h>

#if LOCALE_ON
#include <nl_types.h>
extern nl_catd MsgCat;
#define condcatgets(cat, set, msg, s) (cat ? catgets(cat, set, msg, s) : s)
#else
#define condcatgets(cat, set, msg, s) s
#endif


/*****************************************************************************/
/*                                                                           */
/*  Include, font and database directories, and the DEBUG_ON and ASSERT_ON   */
/*  flags (defined by -D options on the cc command line in the makefile).    */
/*                                                                           */
/*  LATIN         Non-zero means compile for ISO-LATIN-1 char set.           */
/*  LIB_DIR       The system directory where library files are kept          */
/*  INCL_DIR      The subdirectory of LIB_DIR where @Include files are kept  */
/*  FONT_DIR      The subdirectory of LIB_DIR where .AFM font files are kept */
/*  MAPS_DIR      The subdirectory of LIB_DIR where .LCM files are kept      */
/*  DATA_DIR      The subdirectory of LIB_DIR where database files are kept  */
/*  HYPH_DIR      The subdirectory of LIB_DIR where hyphenation files kept   */
/*  LOCALE_DIR    The subdirectory of LIB_DIR where locale files are kept    */
/*  CHAR_IN       Determines assignment of input chars to lex classes        */
/*  CHAR_OUT      Determines appearance of literal chars in output           */
/*  DEBUG_ON      Non-zero means compile debug code (lout -d)                */
/*  ASSERT_ON     Non-zero means test assertions                             */
/*  LOCALE_ON     Non-zero means compile setlocale() etc. code               */
/*                                                                           */
/*  #define  LIB_DIR    "/usr/local/lib/lout"                                */
/*  #define  INCL_DIR   "include"                                            */
/*  #define  FONT_DIR   "font"                                               */
/*  #define  MAPS_DIR   "maps"                                               */
/*  #define  DATA_DIR   "data"                                               */
/*  #define  HYPH_DIR   "hyph"                                               */
/*  #define  LOCALE_DIR "locale"  (only used if LOCALE_ON)                   */
/*  #define  CHAR_IN    0                                                    */
/*  #define  CHAR_OUT   0                                                    */
/*  #define  DEBUG_ON   0                                                    */
/*  #define  ASSERT_ON  1                                                    */
/*  #define  LOCALE_ON  1                                                    */
/*                                                                           */
/*****************************************************************************/


/*@::File naming conventions and version@*************************************/
/*                                                                           */
/*  File naming conventions and version                                      */
/*                                                                           */
/*  LOUT_VERSION        Version information                                  */
/*  CROSS_DB            The default name of the cross reference database     */
/*  SOURCE_SUFFIX       Optional suffix of source files and include files    */
/*  INDEX_SUFFIX        The suffix of database index files                   */
/*  NEW_INDEX_SUFFIX    The suffix of new database index files               */
/*  DATA_SUFFIX         The suffix of database data files                    */
/*  NEW_DATA_SUFFIX     The additional suffix of new database data files     */
/*  HYPH_SUFFIX         The suffix of unpacked hyphenation files             */
/*  HYPH_PACKED_SUFFIX  The suffix of packed hyphenation files               */
/*  FILTER_IN           The prefix of the name of the input file to filters  */
/*  FILTER_OUT          The prefix of the name of the output file to filters */
/*  FILTER_ERR          The name of the error file to filters                */
/*                                                                           */
/*****************************************************************************/

#define	LOUT_VERSION   AsciiToFull("Basser Lout Version 3.38 (September 2008)")
#define	CROSS_DB	   AsciiToFull("lout")
#define	SOURCE_SUFFIX	   AsciiToFull(".lt")
#define	INDEX_SUFFIX	   AsciiToFull(".li")
#define	NEW_INDEX_SUFFIX   AsciiToFull(".lix")
#define	DATA_SUFFIX	   AsciiToFull(".ld")
#define	NEW_DATA_SUFFIX	   AsciiToFull("x")
#define	HYPH_SUFFIX	   AsciiToFull(".lh")
#define	HYPH_PACKED_SUFFIX AsciiToFull(".lp")
#define	FILTER_IN	   AsciiToFull("louti")
#define	FILTER_OUT	   AsciiToFull("lout")
#define	FILTER_ERR	   AsciiToFull("lout.err")


/*****************************************************************************/
/*                                                                           */
/*  Operating system dependent things                                        */
/*                                                                           */
/*  (1) Reading files                                                        */
/*                                                                           */
/*  Starting from Version 3.27, Lout reads all files in "binary mode", so    */
/*  that the actual characters in the file are presented to Lout.  Lout      */
/*  accepts any of LF, CR, LF+CR, CR+LF as a valid line ending on any        */
/*  line of any file, taking the longest match as usual.                     */
/*                                                                           */
/*  This strategy has two major advantages:  files transferred between       */
/*  operating systems are always read correctly without needing any          */
/*  conversion, and ftell() always works properly on binary files (its       */
/*  behaviour on text files has been observed to vary).                      */
/*                                                                           */
/*  READ_FILE         Mode passed to fopen() when reading any file at all    */
/*                                                                           */
/*  (2) Writing files                                                        */
/*                                                                           */
/*  Starting from Version 3.27, Lout writes all files in "binary mode",      */
/*  so that the actual characters in the file are all explicitly written     */
/*  by Lout.  The macro STR_NEWLINE defines what character(s) Lout will      */
/*  write when it wants to end the line; throughout Lout the "\n" thing      */
/*  never appears, only STR_NEWLINE.  STR_NEWLINE is defined below to be     */
/*  "\n" on Unix, "\r\n" on DOS, and "\r" on Mac.                            */
/*                                                                           */
/*  This strategy might seem to be overkill, given that writing "\n" on      */
/*  a DOS text file would write "\r\n" anyway.  Unfortunately, when Lout     */
/*  is writing a database file, it uses ftell() as it is writing to find     */
/*  out where it's up to.  Since we can only be sure that ftell() will       */
/*  work on binary files, we've made all file writing be binary.             */
/*                                                                           */
/*  WRITE_FILE        Mode passed to fopen() when writing any file at all    */
/*  APPEND_FILE       Mode passed to fopen() when appending any file at all  */
/*  STR_NEWLINE       The string to write to a binary file to end a line     */
/*                                                                           */
/*  (3) Directory character                                                  */
/*                                                                           */
/*  Operating systems differ in the character used in path names.            */
/*                                                                           */
/*  STR_DIR           Directory character used in file path names            */
/*                                                                           */
/*  (4) System command and file name for uncompressing EPS files             */
/*                                                                           */
/*  UNCOMPRESS_COM    System command for uncompressing compressed EPS file   */
/*  LOUT_EPS          Name of temporary uncompressed EPS file                */
/*                                                                           */
/*  There is one further call to system() in the Lout source code:  the one  */
/*  that implements filtered parameters such as prg2lout.  The strings       */
/*  passed to this call to system() are the values of @Filter symbols        */
/*  within Lout definitions.                                                 */
/*                                                                           */
/*****************************************************************************/

#if OS_UNIX
#define	READ_FILE	"r"
#define	WRITE_FILE	"w"
#define	APPEND_FILE	"a"
#define	STR_NEWLINE	AsciiToFull("\n")
#define	STR_DIR		AsciiToFull("/")
#define	UNCOMPRESS_COM	"gunzip -c %s > %s"
#define	LOUT_EPS	"lout.eps"
#else
#if OS_DOS
#define	READ_FILE	"rb"
#define	WRITE_FILE	"wb"
#define	APPEND_FILE	"ab"
#define	STR_NEWLINE	AsciiToFull("\r\n")
#define	STR_DIR		AsciiToFull("/")
#define	UNCOMPRESS_COM	"gunzip -c %s > %s"
#define	LOUT_EPS	"lout.eps"
#else
#if OS_MAC
#define	READ_FILE	"r"
#define	WRITE_FILE	"w"
#define	APPEND_FILE	"a"
#define	STR_NEWLINE	AsciiToFull("\r")
#define	STR_DIR		AsciiToFull(":")
#define	UNCOMPRESS_COM	"gunzip -c %s > %s"
#define	LOUT_EPS	"lout.eps"
#else
If you're compiling this, you've got the wrong settings in the makefile!
#endif
#endif
#endif

/*@::Significant limits@******************************************************/
/*                                                                           */
/*  Significant Limits (other insignificant ones appear in other files)      */
/*                                                                           */
/*  MAX_FULL_LENGTH     The maximum value storable in type FULL_LENGTH.      */
/*                      NB this cannot be 2**31 - 1 because there are        */
/*                      intermediate results that exceed MAX_FULL_LENGTH     */
/*                      and are subsequently reduced to MAX_FULL_LENGTH.     */
/*                      For example, some intermediate results may exceed    */
/*                      MAX_FULL_LENGTH by a factor of SF, which is defined  */
/*                      below to be 256 (2**8).  The value given is 2**23-1, */
/*                      which is about 148 metres in Lout's precision.       */
/*                                                                           */
/*  MAX_FILES           The maximum number of files.  This could only be     */
/*                      increased if the file_num() field of type FILE_POS   */
/*                      is enlarged beyond its present 16 bits.              */
/*                                                                           */
/*  MAX_LINE            1 + the maximum length of an input line in source    */
/*                      and database files.  This is used for the lexical    */
/*                      analyser's input line buffer only, and could be      */
/*                      increased immediately to 4096, and even further if   */
/*                      more than the current 12 bits was assigned to the    */
/*                      col_num() field of type FILE_POS.                    */
/*                                                                           */
/*  MAX_WORD            1 + the maximum length of a word storable in an      */
/*                      object record, which includes all file path names    */
/*                      too.  It is reasonable to make this MAX_LINE, since  */
/*                      a word longer than MAX_LINE cannot be read in.       */
/*                                                                           */
/*  MAX_OBJECT_REC      1 + the maximum size of an object record, measured   */
/*                      in ALIGNs.  The value chosen should exceed           */
/*                      ceiling( (wr + MAX_WORD - 4) / sizeof(ALIGN) )       */
/*                      where wr = sizeof(struct word_rec), so that words of */
/*                      length MAX_WORD-1 can be stored in an object record. */
/*                                                                           */
/*  MAX_BUFF            1 + the maximum length of a "standard buffer"; these */
/*                      buffers are used in a variety of places throughout   */
/*                      the program for holding one line of a font file,     */
/*                      one file path name, one symbol full name, etc.  This */
/*                      may be increased immediately without limit.          */
/*                                                                           */
/*  MAX_FONT            The maximum number of sized fonts allowed.           */
/*                                                                           */
/*  MAX_COLOUR          The maximum number of distinct left parameters of    */
/*                      @SetColour and @SetColor symbols allowed (after      */
/*                      evaluation).                                         */
/*                                                                           */
/*  MAX_TEXTURE         The maximum number of distinct left parameters of    */
/*                      the @SetTexture symbol allowed (after evaluation).   */
/*                                                                           */
/*  MAX_LANGUAGE        The maximum number of distinct languages allowed.    */
/*                      This can be increased beyond 256 only by setting     */
/*                      aside a larger word_language() field.                */
/*                                                                           */
/*  MAX_LEX_STACK       The maximum depth of @Includes and @Databases.  This */
/*                      can be increased immediately by any small amount.    */
/*                                                                           */
/*  MAX_CHARS		The maximimum number of characters in a font.  This  */
/*                      cannot be increased easily.                          */
/*                                                                           */
/*  MAX_HCOPIES         The maximimum number of copies of one running header */
/*                      that can appear correctly on one page.  Can be       */
/*                      increased to any small positive integer.             */
/*                                                                           */
/*****************************************************************************/

#define	MAX_FULL_LENGTH	8388607	/* 2**23 - 1, about 148 metres */
#define	MAX_FILES	65535
#define MAX_LINE        2048
#define MAX_WORD        2048
#define	MAX_OBJECT_REC	ceiling(sizeof(struct word_type)+MAX_WORD,sizeof(ALIGN))
#define MAX_BUFF        512
#define MAX_FONT	65535
#define MAX_COLOUR	65535
#define MAX_TEXTURE	65535
#define	MAX_LANGUAGE	64
#define	MAX_LEX_STACK	20
#define	MAX_CHARS	256
#define MAX_HCOPIES	3

/*****************************************************************************/
/*                                                                           */
/*  Miscellaneous Macros                                                     */
/*                                                                           */
/*****************************************************************************/

#define	BOOLEAN		unsigned
#define	FALSE		0
#define	TRUE		1
#define	bool(x)		(x ? AsciiToFull("TRUE") : AsciiToFull("FALSE") )
#define	CHILD		0
#define	PARENT		1
#define	COLM		0
#define	ROWM		1
#define	dimen(x)	(x == COLM ? AsciiToFull("COLM") : AsciiToFull("ROWM") )
#define	nilobj		( (OBJECT) NULL )
#define	null		( (FILE *) NULL )

#define find_max(a, b)	((a) < (b) ? (b) : (a))
#define find_min(a, b)	((a) < (b) ? (a) : (b))
#define	ceiling(a, b)	( ((a) - 1)/(b) + 1 )	/* ceiling(a/b)              */
#define is_odd(x)	( (x) & 1 )		/* TRUE if x is odd number   */

/*@::Some straightforward typedefs@*******************************************/
/*                                                                           */
/*  typedef ALIGN - used for forcing record alignment.                       */
/*                                                                           */
/*****************************************************************************/

typedef char *ALIGN;


/*****************************************************************************/
/*                                                                           */
/*  typedef FULL_LENGTH - an integer physical distance.                      */
/*                                                                           */
/*****************************************************************************/

typedef int FULL_LENGTH;


/*****************************************************************************/
/*                                                                           */
/*  FONT_NUM - internal name for a font.                                     */
/*                                                                           */
/*****************************************************************************/

typedef unsigned short FONT_NUM;


/*****************************************************************************/
/*                                                                           */
/*  COLOUR_NUM - internal name for a colour.                                 */
/*                                                                           */
/*****************************************************************************/

typedef unsigned short COLOUR_NUM;


/*****************************************************************************/
/*                                                                           */
/*  TEXTURE_NUM - internal name for a texture.                               */
/*                                                                           */
/*****************************************************************************/

typedef unsigned short TEXTURE_NUM;


/*****************************************************************************/
/*                                                                           */
/*  LANGUAGE_NUM - internal name for a language.                             */
/*                                                                           */
/*****************************************************************************/

typedef unsigned int LANGUAGE_NUM;


/*****************************************************************************/
/*                                                                           */
/*  MAPPING - internal name for a character mapping vector.                  */
/*                                                                           */
/*****************************************************************************/

typedef unsigned int MAPPING;


/*****************************************************************************/
/*                                                                           */
/*  LINE - a line from a database index file.                                */
/*                                                                           */
/*****************************************************************************/

typedef char *LINE;


/*****************************************************************************/
/*                                                                           */
/*  typedef FULL_CHAR - one of the characters manipulated by Lout.           */
/*                                                                           */
/*  This program does not deal with 7-bit ASCII characters.  Instead, its    */
/*  characters are defined by the FULL_CHAR typedef, and could be anything   */
/*  from 7-bit ASCII to 8-bit ISO-LATIN-1 to 16-bit UNICODE and beyond.      */
/*                                                                           */
/*  Unfortunately C favours signed 8-bit characters: literal strings are     */
/*  pointers to them, argv[] and the standard libraries assume them.  We get */
/*  around these problems by using our own library, including AsciiToFull()  */
/*  to convert an ASCII string (such as a C string) into a FULL_CHAR string. */
/*                                                                           */
/*  Formally this library appears in module z39.c; however since this        */
/*  implementation uses 8-bit unsigned characters, most of the routines      */
/*  can be implemented by macros containing type-cast calls to C standard    */
/*  library routines.  These appear in the z39.c externs list below.         */
/*                                                                           */
/*****************************************************************************/

typedef unsigned char FULL_CHAR;

/*****************************************************************************/
/*                                                                           */
/*  typedef POINTER- name for type of generic pointer                        */
/*                                                                           */
/*****************************************************************************/

typedef void *POINTER;

/*@::Character literals@******************************************************/
/*                                                                           */
/*  Character Literals                                                       */
/*                                                                           */
/*  The following macros ensure that no Lout source is ever compared to a    */
/*  literal character other than '\0':                                       */
/*                                                                           */
/*****************************************************************************/

#define	CH_FLAG_ALTERR		'a'	/* the -a command line flag          */
#define	CH_FLAG_CROSS		'c'	/* the -c command line flag          */
#define	CH_FLAG_ENCPATH		'C'	/* the -C command line flag          */
#define	CH_FLAG_DEBUG		'd'	/* the -d command line flag          */
#define	CH_FLAG_DIRPATH		'D'	/* the -D command line flag          */
#define	CH_FLAG_ERRFILE		'e'	/* the -e command line flag          */
#define	CH_FLAG_EPSFIRST	'E'	/* first letter of the -EPS flag     */
#define	CH_FLAG_FNTPATH		'F'	/* the -F command line flag          */
#define	CH_FLAG_HYPHEN		'h'	/* the -h command line flag          */
#define	CH_FLAG_HYPPATH		'H'	/* the -H command line flag          */
#define	CH_FLAG_INCLUDE		'i'	/* the -i command line flag          */
#define	CH_FLAG_INCPATH		'I'	/* the -I command line flag          */
#define	CH_FLAG_NOKERN		'k'	/* the -k command line flag          */
#define CH_FLAG_NOCOLLATE       'l'     /* the -l command line flag          */
#define CH_FLAG_COLLATE         'L'     /* the -L command line flag          */
#define CH_FLAG_MEMCHECK        'm'     /* the -m command line flag          */
#define	CH_FLAG_MEMCR		'M'	/* the -M command line flag	     */
#define	CH_FLAG_OUTFILE		'o'	/* the -o command line flag          */
#define	CH_FLAG_PLAIN		'p'	/* the -p command line flag          */
#define	CH_FLAG_FFPLAIN		'P'	/* the -P command line flag          */
#define	CH_FLAG_RUNS		'r'	/* the -r command line flag          */
#define	CH_FLAG_SUPPRESS	's'	/* the -s command line flag          */
#define	CH_FLAG_SAFE		'S'	/* the -S command line flag          */
#define	CH_FLAG_NOTEXTURE	't'	/* the -t command line flag          */
#define	CH_FLAG_USAGE		'u'	/* the -u command line flag          */
#define	CH_FLAG_UNSAFE		'U'	/* the -U command line flag          */
#define	CH_FLAG_VERSION		'V'	/* the -V command line flag          */
#define	CH_FLAG_INITALL		'x'	/* the -x command line flag          */
#define	CH_FLAG_OPTION		'-'	/* the -- command line flag          */
#define	CH_FLAG_WORDS		'w'	/* the -w command line flag          */
#define	CH_FLAG_PDF		'Z'	/* the -Z command line flag	     */

#define	CH_SPACE		' '	/* space character                   */
/* #define	CH_NEWLINE		'\n'*/ 	/* the newline character     */
#define	CH_LF			'\n'	/* the line feed character           */
#define	CH_CR			'\r'	/* the carriage return character     */
#define	CH_SYMSTART		'@'	/* extra letter symbols may have     */
#define	CH_UNDERSCORE		'_'	/* extra letter symbols may have     */
#define	CH_QUOTE		'"'	/* the quote character		     */
#define	CH_ZERO			'0'	/* the first digit character, zero   */
#define	CH_EIGHT		'8'	/* the last even digit character     */
#define	CH_NINE			'9'	/* the last odd digit character      */
#define	CH_INCGAP		'+'	/* begins an incrementing gap	     */
#define	CH_DECGAP		'-'	/* begins a decrementing gap	     */
#define	CH_MINUS		'-'	/* minus sign                        */
#define	CH_HYPHEN		'-'	/* the hyphen character		     */
#define	CH_SLASH		'/'	/* the slash character		     */
#define	CH_NOBREAK		'u'	/* `unbreakable' character for gaps  */

#define	CH_UNIT_CM		'c'	/* unit of measurement: centimetres  */
#define	CH_UNIT_IN		'i'	/* unit of measurement: inches       */
#define	CH_UNIT_PT		'p'	/* unit of measurement: points       */
#define	CH_UNIT_EM		'm'	/* unit of measurement: ems          */
#define	CH_UNIT_FT		'f'	/* unit of measurement: fontsizes    */
#define	CH_UNIT_SP		's'	/* unit of measurement: spacewidths  */
#define	CH_UNIT_VS		'v'	/* unit of measurement: vspaces      */
#define	CH_UNIT_WD		'w'	/* unit of measurement: follwidths   */
#define	CH_UNIT_BD		'b'	/* unit of measurement: boundwidths  */
#define	CH_UNIT_RL		'r'	/* unit of measurement: relwidths    */
#define	CH_UNIT_DG		'd'	/* unit of measurement: degrees      */
#define	CH_UNIT_YU		'y'	/* unit of measurement: y unit       */
#define	CH_UNIT_ZU		'z'	/* unit of measurement: z unit       */

#define	CH_MODE_EDGE		'e'	/* spacing mode: edge-to-edge        */
#define	CH_MODE_HYPH		'h'	/* spacing mode: hyphenation         */
#define	CH_MODE_MARK		'x'	/* spacing mode: mark-to-mark        */
#define	CH_MODE_OVER		'o'	/* spacing mode: overstrike          */
#define	CH_MODE_KERN		'k'	/* spacing mode: kerning             */
#define	CH_MODE_TABL		't'	/* spacing mode: tabulation          */

#define octaldigit(ch)		( (ch) >= '0' && (ch) <= '7' )
#define decimaldigit(ch)	( (ch) >= '0' && (ch) <= '9' )
#define	digitchartonum(ch)	( (ch) - '0' )
#define	numtodigitchar(ch)	( (ch) + '0' )
#define	beginsbreakstyle(ch)	( (ch) >= 'a' && (ch) <= 'z' )
#define	numericchar(ch)		( decimaldigit(ch) || (ch) == '.' )


/*@::String literals, FULL_CHAR type@*****************************************/
/*                                                                           */
/*  String Literals.                                                         */
/*                                                                           */
/*  All significant string literals are defined here.  The program has many  */
/*  others, however: format strings, debug output, etc.                      */
/*                                                                           */
/*****************************************************************************/

#define	STR_EMPTY		AsciiToFull("")
#define	STR_QUOTE		AsciiToFull("\"")
#define	STR_ESCAPE		AsciiToFull("\\")
#define	STR_COMMENT		AsciiToFull("#")
#define	STR_SPACE		AsciiToFull(" ")
#define	STR_FORMFEED		AsciiToFull("\f")
#define	STR_TAB			AsciiToFull("\t")
#define	STR_LETTERS_LOWER	AsciiToFull("abcdefghijklmnopqrstuvwxyz")
#define	STR_LETTERS_UPPER	AsciiToFull("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#define	STR_LETTERS_SYMSTART	AsciiToFull("@")
#define	STR_LETTERS_UNDERSCORE	AsciiToFull("_")

#if CHAR_IN==0
#define	STR_LETTERS_EXTRA0	AsciiToFull("")
#define	STR_LETTERS_EXTRA1	AsciiToFull("")
#define	STR_LETTERS_EXTRA2	AsciiToFull("")
#define	STR_LETTERS_EXTRA3	AsciiToFull("")
#define	STR_LETTERS_EXTRA4	AsciiToFull("")
#define	STR_LETTERS_EXTRA5	AsciiToFull("")
#define	STR_LETTERS_EXTRA6	AsciiToFull("")
#define	STR_LETTERS_EXTRA7	AsciiToFull("")
#else
#define	STR_LETTERS_EXTRA0	AsciiToFull("\300\301\302\303\304\305\306\307")
#define	STR_LETTERS_EXTRA1	AsciiToFull("\310\311\312\313\314\315\316\317")
#define	STR_LETTERS_EXTRA2	AsciiToFull("\320\321\322\323\324\325\326")
#define	STR_LETTERS_EXTRA3	AsciiToFull("\330\331\332\333\334\335\336\337")
#define	STR_LETTERS_EXTRA4	AsciiToFull("\340\341\342\343\344\345\346\347")
#define	STR_LETTERS_EXTRA5	AsciiToFull("\350\351\352\353\354\355\356\357")
#define	STR_LETTERS_EXTRA6	AsciiToFull("\360\361\362\363\364\365\366")
#define	STR_LETTERS_EXTRA7	AsciiToFull("\370\371\372\373\374\375\376\377")
#endif

#define	STR_STDIN		AsciiToFull("-")
#define	STR_STDOUT		AsciiToFull("-")
#define	STR_HYPHEN		AsciiToFull("-")
#define	STR_EPS			AsciiToFull("EPS")
#define	STR_POSTSCRIPT		AsciiToFull("PostScript")
#define	STR_PLAINTEXT		AsciiToFull("PlainText")
#define	STR_PDF			AsciiToFull("PDF")
#define	STR_ELSE		AsciiToFull("else")
#define	STR_NOCROSS		AsciiToFull("??")
#define	STR_BADKEY		AsciiToFull("badkey")
#define	STR_NONE		AsciiToFull("none")
#define	STR_NOCHAR		AsciiToFull("-none-")
#define	STR_ZERO		AsciiToFull("0")
#define	STR_PS_SPACENAME	AsciiToFull("space")
#define	STR_FONT_RECODE		AsciiToFull("Recode")
#define	STR_FONT_NORECODE	AsciiToFull("NoRecode")
#define	STR_COLOUR_NOCHANGE	AsciiToFull("nochange")
#define	STR_TEXTURE_NOCHANGE	AsciiToFull("nochange")

#define	STR_BREAK_HYPHEN	AsciiToFull("hyphen")
#define	STR_BREAK_NOHYPHEN	AsciiToFull("nohyphen")
#define	STR_BREAK_ADJUST	AsciiToFull("adjust")
#define	STR_BREAK_OUTDENT	AsciiToFull("outdent")
#define	STR_BREAK_RAGGED	AsciiToFull("ragged")
#define	STR_BREAK_CRAGGED	AsciiToFull("cragged")
#define	STR_BREAK_RRAGGED	AsciiToFull("rragged")
#define	STR_BREAK_ORAGGED	AsciiToFull("oragged")
#define	STR_BREAK_LINES		AsciiToFull("lines")
#define	STR_BREAK_CLINES	AsciiToFull("clines")
#define	STR_BREAK_RLINES	AsciiToFull("rlines")
#define	STR_BREAK_OLINES	AsciiToFull("olines")
#define	STR_BREAK_SCALE		AsciiToFull("blanklinescale")
#define	STR_BREAK_NOFIRST	AsciiToFull("unbreakablefirst")
#define	STR_BREAK_FIRST		AsciiToFull("breakablefirst")
#define	STR_BREAK_NOLAST	AsciiToFull("unbreakablelast")
#define	STR_BREAK_LAST		AsciiToFull("breakablelast")
#define	STR_BREAK_SETOUTDENT	AsciiToFull("setoutdent")
#define STR_BREAK_MARGINKERNING AsciiToFull("marginkerning")
#define STR_BREAK_NOMARGINKERNING AsciiToFull("nomarginkerning")

#define STR_SPACE_LOUT		AsciiToFull("lout")
#define STR_SPACE_COMPRESS	AsciiToFull("compress")
#define STR_SPACE_SEPARATE	AsciiToFull("separate")
#define STR_SPACE_TROFF		AsciiToFull("troff")
#define STR_SPACE_TEX		AsciiToFull("tex")

#define	STR_SMALL_CAPS_ON	AsciiToFull("smallcaps")
#define	STR_SMALL_CAPS_OFF	AsciiToFull("nosmallcaps")
#define	STR_SMALL_CAPS_SET	AsciiToFull("setsmallcaps")
#define	STR_BASELINE_MARK	AsciiToFull("baselinemark")
#define	STR_LIG			AsciiToFull("lig")
#define	STR_NOLIG		AsciiToFull("nolig")
#define	STR_XHEIGHT2_MARK	AsciiToFull("xheight2mark")
#define	STR_NOSTRUT		AsciiToFull("nostrut")
#define	STR_STRUT		AsciiToFull("strut")

#define	STR_GAP_RJUSTIFY	AsciiToFull("1rt")
#define	STR_GAP_ZERO_HYPH	AsciiToFull("0ch")

#define	STR_SCALE_DOWN		AsciiToFull("downifneeded")


/*@::GAP, STYLE@**************************************************************/
/*                                                                           */
/*  typedef GAP - what separates one object from another.                    */
/*                                                                           */
/*****************************************************************************/

typedef struct
{ FULL_LENGTH	owidth;			/* width of the gap                  */
  BOOLEAN	onobreak : 1;		/* TRUE if this gap is unbreakable   */
  BOOLEAN	omark	 : 1;		/* TRUE if this gap is marked        */
  BOOLEAN	ojoin	 : 1;		/* TRUE if joins exist across gap    */
  unsigned	ounits	 : 3;		/* units of measurement: fixed, etc  */
  unsigned	omode	 : 3;		/* spacing mode: edge-to-edge, etc   */
} GAP;

#define	nobreak(x)	(x).onobreak
#define	mark(x)		(x).omark
#define	join(x)		(x).ojoin
#define	units(x)	(x).ounits
#define	mode(x)		(x).omode
#define	width(x)	(x).owidth

#define SetGap(x, xnobreak, xmark, xjoin, xunits, xmode, xwidth)	\
( nobreak(x) = xnobreak, mark(x) = xmark, join(x) = xjoin,		\
  units(x) = xunits, mode(x) = xmode, width(x) = xwidth			\
)

#define GapCopy(x, y)							\
( nobreak(x) = nobreak(y), mark(x) = mark(y), join(x) = join(y),	\
  units(x) = units(y), mode(x) = mode(y), width(x) = width(y)		\
)

#define GapEqual(x, y)							\
( nobreak(x) == nobreak(y) && mark(x) == mark(y) && join(x) == join(y)	\
  && units(x) == units(y) && mode(x) == mode(y) && width(x) == width(y)	\
)

#define ClearGap(x)	SetGap(x, FALSE, FALSE, TRUE, FIXED_UNIT, NO_MODE, 0)


/*****************************************************************************/
/*                                                                           */
/*  typedef STYLE - information about how to break text, etc.                */
/*                                                                           */
/*****************************************************************************/

/* A key-value pair.  */
typedef struct context_type
{
  union rec	    *okey;		/* name of a context variable        */
  union rec	    *ovalue;		/* associated value		     */
  union rec         *oenv;		/* environment for this value        */
  struct style_type *ostyle;		/* style for this value              */
} CONTEXT;

#define	context_key(x)		(x).okey
#define	context_value(x)	(x).ovalue
#define	context_env(x)		(x).oenv
#define	context_style(x)	(x).ostyle

typedef struct style_type
{
  GAP		oline_gap;		/* separation between lines          */
  GAP		ospace_gap;		/* separation induced by white space */
  FULL_LENGTH	oyunit;			/* value of y unit of measurement    */
  FULL_LENGTH	ozunit;			/* value of z unit of measurement    */
  FULL_LENGTH	ooutdent_len;		/* amount to outdent in outdent style*/
  FULL_LENGTH	osmallcaps_len;		/* size of small capitals            */
  FONT_NUM	ofont;			/* current font                      */
  COLOUR_NUM	ocolour;		/* current colour		     */
  COLOUR_NUM	ounderline_colour;	/* current underline colour	     */
  TEXTURE_NUM	otexture;		/* current texture		     */
  unsigned short oblanklinescale;	/* scale factor for blank lines      */
  LANGUAGE_NUM	olanguage       : 6;	/* current language		     */
  BOOLEAN	ovadjust	: 1;	/* @VAdjust in effect                */
  BOOLEAN	ohadjust	: 1;	/* @HAdjust in effect                */
  BOOLEAN	opadjust	: 1;	/* @PAdjust in effect                */
  unsigned	osmall_caps	: 1;	/* small capitals                    */
  unsigned	ospace_style	: 3;	/* space style: lout, troff, tex, .. */
  unsigned	ohyph_style	: 2;	/* hyphenation off or on             */
  unsigned	ofill_style	: 2;	/* fill lines with text off/on       */
  unsigned	odisplay_style	: 3;	/* display lines adjusted, ragged... */
  BOOLEAN	ooutline	: 2;	/* TRUE if outlining words           */
  BOOLEAN	onobreakfirst	: 1;	/* no break after first line of para */
  BOOLEAN	onobreaklast	: 1;	/* no break after last line of para  */
  BOOLEAN	obaselinemark	: 1;	/* baseline char metrics             */
  BOOLEAN	ostrut		: 1;	/* strut char metrics                */
  BOOLEAN	oligatures	: 1;	/* use ligatures                     */
  BOOLEAN	omarginkerning	: 1;	/* perform margin kerning            */
  CONTEXT	ocontext;		/* context stack		     */
} STYLE;

#define	line_gap(x)	(x).oline_gap
#define	space_gap(x)	(x).ospace_gap
#define	yunit(x)	(x).oyunit
#define	zunit(x)	(x).ozunit
#define	outdent_len(x)	(x).ooutdent_len
#define	smallcaps_len(x)(x).osmallcaps_len
#define	font(x)		(x).ofont
#define	colour(x)	(x).ocolour
#define	underline_colour(x) (x).ounderline_colour
#define	texture(x)	(x).otexture
#define	blanklinescale(x)(x).oblanklinescale
#define	language(x)	(x).olanguage
#define	vadjust(x)	(x).ovadjust
#define	hadjust(x)	(x).ohadjust
#define	padjust(x)	(x).opadjust
#define	small_caps(x)	(x).osmall_caps
#define	space_style(x)	(x).ospace_style
#define	hyph_style(x)	(x).ohyph_style
#define	fill_style(x)	(x).ofill_style
#define	display_style(x)(x).odisplay_style
#define	outline(x)	(x).ooutline
#define	nobreakfirst(x)	(x).onobreakfirst
#define	nobreaklast(x)	(x).onobreaklast
#define	baselinemark(x)	(x).obaselinemark
#define	strut(x)	(x).ostrut
#define	ligatures(x)	(x).oligatures
#define	marginkerning(x)(x).omarginkerning
#define	context(x)	(x).ocontext

#define StyleCopy(x, y)							\
( GapCopy(line_gap(x), line_gap(y)),					\
  GapCopy(space_gap(x), space_gap(y)),					\
  yunit(x) = yunit(y),							\
  zunit(x) = zunit(y),							\
  outdent_len(x) = outdent_len(y),					\
  smallcaps_len(x) = smallcaps_len(y),					\
  font(x) = font(y),							\
  colour(x) = colour(y),						\
  underline_colour(x) = underline_colour(y),				\
  texture(x) = texture(y),						\
  blanklinescale(x) = blanklinescale(y),				\
  language(x) = language(y), 						\
  vadjust(x) = vadjust(y), 						\
  hadjust(x) = hadjust(y), 						\
  padjust(x) = padjust(y), 						\
  small_caps(x) = small_caps(y),					\
  space_style(x) = space_style(y),					\
  hyph_style(x) = hyph_style(y),					\
  fill_style(x) = fill_style(y),					\
  display_style(x) = display_style(y),					\
  outline(x) = outline(y),						\
  nobreakfirst(x) = nobreakfirst(y),					\
  nobreaklast(x) = nobreaklast(y),					\
  baselinemark(x) = baselinemark(y),					\
  strut(x) = strut(y),							\
  ligatures(x) = ligatures(y),						\
  marginkerning(x) = marginkerning(y),					\
  context(x) = context(y)						\
)


/*@::CONSTRAINT, FILE_NUM, FILE_POS, LIST@************************************/
/*                                                                           */
/*  typedef CONSTRAINT - a size constraint.                                  */
/*                                                                           */
/*****************************************************************************/

typedef struct
{ FULL_LENGTH  obc;
  FULL_LENGTH  obfc;
  FULL_LENGTH  ofc;
  FULL_LENGTH  osparec;
} CONSTRAINT;

#define	bc(x)		(x).obc
#define	bfc(x)		(x).obfc
#define	fc(x)		(x).ofc
#define	sparec(x)	(x).osparec
#define	constrained(x)	(bc(x) != MAX_FULL_LENGTH ||			\
			 bfc(x) != MAX_FULL_LENGTH || fc(x) != MAX_FULL_LENGTH)

#define	SetConstraint(c,x,y,z)	(bc(c) = (x),   bfc(c) = (y),    fc(c) = (z))
#define	CopyConstraint(x, y)	(bc(x) = bc(y), bfc(x) = bfc(y), fc(x) = fc(y))
#define	FlipConstraint(x, y)	(bc(x) = fc(y), bfc(x) = bfc(y), fc(x) = bc(y))
#define FitsConstraint(b, f, c)	(b <= bc(c)  && b + f <= bfc(c) && f <= fc(c))
#define EqualConstraint(a, b) (bc(a)==bc(b) && bfc(a)==bfc(b) && fc(a)==fc(b) )

#define	ig_fnum(x)	bc(constraint(x))
#define	ig_xtrans(x)	bfc(constraint(x))
#define	ig_ytrans(x)	fc(constraint(x))


/*****************************************************************************/
/*                                                                           */
/*  typedef FILE_NUM - the internal representation of a file.                */
/*                                                                           */
/*****************************************************************************/

typedef unsigned short	FILE_NUM;
#define	NO_FILE		0


/*****************************************************************************/
/*                                                                           */
/*  typedef FILE_POS - a position in the set of input files.                 */
/*                                                                           */
/*****************************************************************************/

typedef	struct
{ unsigned char	 otype;			/* space for object type field	     */
  unsigned char	 orec_size;		/* space for object record size      */
  FILE_NUM	 ofile_num;		/* no. of file this record is from   */
  unsigned       oline_num  : 20;	/* the line number of this record    */
  unsigned       ocol_num   : 12;	/* column number this is related to  */
} FILE_POS;

#define	file_num(x)	(x).ofile_num
#define	col_num(x)	(x).ocol_num
#define	line_num(x)	(x).oline_num

#define FposCopy(x, y)							\
( file_num(x) = file_num(y),						\
  line_num(x) = line_num(y),						\
  col_num(x)  = col_num(y)						\
)


/*****************************************************************************/
/*                                                                           */
/*  typedef LIST - two pointers used to make one doubly linked list          */
/*                                                                           */
/*****************************************************************************/

typedef struct { union rec *opred, *osucc; } LIST;


/*@::FIRST_UNION@*************************************************************/
/*                                                                           */
/*  typedef FIRST_UNION - first eight bytes of object record (after LISTs).  */
/*                                                                           */
/*  The fpos is overwritten in WORDs and QWORDs during FixAndPrintObject by  */
/*  the horizontal coordinate of the word, which has to be remembered.       */
/*  This part of the record is also used by font records to hold font        */
/*  bounding box data.                                                       */
/*                                                                           */
/*****************************************************************************/

typedef union
{
  FILE_POS	ofpos;
  struct
  {	unsigned char	otype, orec_size;
	int		oword_save_mark;
  } os11;

} FIRST_UNION;


/*@::SECOND_UNION, THIRD_UNION, FOURTH_UNION@*********************************/
/*                                                                           */
/*  typedef SECOND_UNION - twelve bytes holding various flags etc.           */
/*                                                                           */
/*****************************************************************************/

typedef union
{
  struct /* used by all tokens */
  {	unsigned char	oprecedence;
	unsigned char	ohspace, ovspace;
  } os21;

  struct /* used by WORD objects only, except underline used by all */
	 /* objects, including GAP_OBJ                              */
  {	FONT_NUM	oword_font;
	COLOUR_NUM	oword_colour;
	COLOUR_NUM	oword_underline_colour;
	TEXTURE_NUM	oword_texture;
	unsigned	ounderline	   : 2; /* aligns with os23.underline */
	BOOLEAN		oword_outline	   : 1;
	LANGUAGE_NUM	oword_language	   : 6;
	BOOLEAN		oword_baselinemark : 1;
	BOOLEAN		oword_strut	   : 1;
	BOOLEAN		oword_ligatures	   : 1;
	unsigned	oword_hyph	   : 1;
  } os22;

  struct /* used by non-WORD objects */
  {	unsigned short	ofoll_or_prec;
	unsigned short	ocross_type;	     /* CROSS objects only */
	unsigned short  ounused_os23_a;
	unsigned short  ounused_os23_b;
	unsigned	ounderline   : 2;    /* aligns with os22.underline */
	BOOLEAN		onon_blocking: 1;
	BOOLEAN		osized       : 1;
	BOOLEAN		othreaded    : 1;
	BOOLEAN		oexternal_hor: 1;
	BOOLEAN		oexternal_ver: 1;
	BOOLEAN		oblocked     : 1;
	BOOLEAN		otrigger_ext : 1;
	BOOLEAN	        omust_expand : 1;
	BOOLEAN		ogall_dir    : 1;
	BOOLEAN		oopt_hyph    : 1;
	BOOLEAN		oopt_gazumped: 1;
	BOOLEAN		oadjust_cat  : 1;
	BOOLEAN		oforce_gall  : 1;
	/* don't forget ounderline from os22 applies in this union! */
  } os23;

  struct /* used by WORD and QWORD when they are database nodes */
  {	unsigned short	oleft_pos;
	unsigned char	oreading;
	unsigned char	oin_memory;
  } os24;

  struct /* used by WORD and QWORD when they are font records */
  {
    	FULL_LENGTH	ofont_bbox_lly;
    	FULL_LENGTH	ofont_bbox_ury;
  } os25;

  struct /* used by symbol table entries */
  {	unsigned char	oprecedence;
	BOOLEAN		ois_tag		     : 1;
	BOOLEAN		ohas_tag             : 1;
	BOOLEAN		ohas_lpar            : 1;
	BOOLEAN		ohas_rpar            : 1;
	BOOLEAN		oright_assoc         : 1;
	BOOLEAN		ois_target           : 1;
	BOOLEAN		ohas_target          : 1;
	BOOLEAN		oforce_target	     : 1;
	BOOLEAN		ohas_body            : 1;
	BOOLEAN		oindefinite          : 1;
	BOOLEAN		orecursive           : 1;
	BOOLEAN		ouses_extern_target  : 1;
	BOOLEAN		ois_extern_target    : 1;
	BOOLEAN		ois_key		     : 1;
	BOOLEAN		ohas_key	     : 1;
	BOOLEAN		odirty               : 1;
	BOOLEAN		ovisible	     : 1;
	BOOLEAN		ohas_mark	     : 1;
	BOOLEAN		ohas_join	     : 1;
	BOOLEAN		ohas_par             : 1;
	BOOLEAN		ouses_galley	     : 1;
	BOOLEAN		ohoriz_galley	     : 1;
	BOOLEAN		oimports_encl	     : 1;
  } os26;

} SECOND_UNION;


/*****************************************************************************/
/*                                                                           */
/*  typedef THIRD_UNION - sixteen bytes usually holding an object size.      */
/*                                                                           */
/*  In database records this space is used for a file pointer, or a pointer  */
/*  to a LINE array if the database is in-memory; in certain                 */
/*  WORD objects used privately in z10.c it is used for a galley-position.   */
/*  In font records it holds the font size, space width, etc.  In filter     */
/*  words it holds a pointer to the symbol being filtered.                   */
/*                                                                           */
/*****************************************************************************/

typedef union
{
  struct
  {	FULL_LENGTH	oback[2];
	FULL_LENGTH	ofwd[2];
  } os31;

  FILE *odb_filep;
  LINE *odb_lines;

  struct
  {	FULL_LENGTH	ofont_size;
	FULL_LENGTH	ofont_xheight2;
	FULL_LENGTH	ofont_spacewidth;
    	FONT_NUM	ofont_num;
	unsigned short	ofont_page;
	MAPPING		ofont_mapping	: 7;
	BOOLEAN		ofont_recoded	: 1;
  } os32;

  struct
  {	unsigned char	ocs_type;
	FILE_NUM	ocs_fnum;
	int		ocs_pos;
	int		ocs_lnum;
  } os33;

  struct /* words used as file definitions */
  {
	unsigned int	oline_count;
	unsigned short	ofile_number;
	unsigned char	otype_of_file;
	unsigned char	oused_suffix;
	unsigned char	oupdated;
	unsigned char	opath;
  } os34;

  union rec *ofilter_actual;

} THIRD_UNION;


/*****************************************************************************/
/*                                                                           */
/*  typedef FOURTH_UNION - 11 32-bit words holding a STYLE or CONSTRAINT.    */
/*                                                                           */
/*****************************************************************************/

typedef union
{
  STYLE		osave_style;
  CONSTRAINT	oconstraint;

} FOURTH_UNION;


/*@::OBJECT@******************************************************************/
/*                                                                           */
/*  typedef OBJECT - the general-purpose record used throughout Lout.        */
/*                                                                           */
/*  This record is a complex union type.  Which fields are defined in any    */
/*  given record depends on its type() tag field, as follows.  But first     */
/*  we define some collections of fields that are commonly defined together. */
/*                                                                           */
/*  ALL - these fields are defined in all objects.  They won't be mentioned  */
/*        again, but they are always there.                                  */
/*                                                                           */
/*      type            Tag field for the record                             */
/*      rec_size        Size of this record, in words (for memory allocator) */
/*      succ            Next element on list of parents, children            */
/*      pred            Previous element on list of parents, children        */
/*      fpos            Position in input file which gave rise to this       */
/*                      object (could be null; overwritten by word_save_mark */
/*                      locally in FixAndPrintOjbect).  It sub-fields are:   */
/*                                                                           */
/*                          file_num   internal file number                  */
/*                          line_num   line number in that file              */
/*                          col_num    column number on that line            */
/*                                                                           */
/*                      Lout attempts to put a meaningful fpos into every    */
/*                      object, so that error messages related to that       */
/*                      object can have meaningful line numbers.  This has   */
/*                      not been done in every case; it ought to be.         */
/*                                                                           */
/*  TOKEN - these fields are defined for all objects that are input tokens.  */
/*          They may be overwritten after parsing is completed.              */
/*                                                                           */
/*      precedence      Precedence of this token (0 if has no parameters)    */
/*      hspace          Horizontal space preceding this token                */
/*      vspace          Vertical space preceding this token                  */
/*                                                                           */
/*  SIZED - these fields are defined for all objects that represent Lout     */
/*          objects and hence have a horizontal and vertical size.  They     */
/*          will be undefined until after MinSize() is called on the object, */
/*          and defined thereafter.                                          */
/*                                                                           */
/*      back[COLM]      Horizontal size to left of object's mark             */
/*      fwd[COLM]       Horizontal size to right of object's mark            */
/*      back[ROWM]      Vertical size above object's mark                    */
/*      fwd[ROWM]       Vertical size below object's mark                    */
/*                                                                           */
/*  GAP - a gap between two Lout objects.                                    */
/*                                                                           */
/*      nobreak         TRUE if gap is unbreakable (has u tag)               */
/*      mark            TRUE if gap is marked (has ^ tag)                    */
/*      join            TRUE if a mark-joining gap (e.g. | not ||)           */
/*      units           units of measurement (fixed, or r or d etc)          */
/*      mode            gap mode (mark-to-mark, etc.)                        */
/*      width           width of gap in the given units                      */
/*                                                                           */
/*  STYLE - the style (attributes affecting the appearance) of an object.    */
/*                                                                           */
/*      line_gap        separation between lines                             */
/*      space_gap       separation induced by white space                    */
/*      yunit           value of y unit of measurement                       */
/*      zunit           value of z unit of measurement                       */
/*      outdent_len     amount to outdent in outdent style                   */
/*      smallcaps_len   size of small capitals                               */
/*      font            current font                                         */
/*      colour          current colour		                             */
/*      texture         current texture		                             */
/*      blanklinescale  scale factor for blank lines                         */
/*      language        current language		                     */
/*      vadjust	        @VAdjust in effect                                   */
/*      hadjust	        @HAdjust in effect                                   */
/*      padjust	        @PAdjust in effect                                   */
/*      small_caps	small capitals                                       */
/*      space_style	space style: lout, troff, tex, ..                    */
/*      hyph_style	hyphenation off or on                                */
/*      fill_style	fill lines with text off/on                          */
/*      display_style	display lines adjusted, ragged...                    */
/*      outline	: 2     TRUE if outlining words                              */
/*      nobreakfirst	no break after first line of para                    */
/*      nobreaklast	no break after last line of para                     */
/*      baselinemark	baseline char metrics                                */
/*      strut       	strut char metrics                                   */
/*      ligatures	use ligatures                                        */
/*      marginkerning	perform margin kerning                               */
/*                                                                           */
/*  CONSTRAINT - a constraint on how large some object is allowed to be,     */
/*               either horizontally or vertically                           */
/*                                                                           */
/*      bc              how large back may be (MAX_FULL_LEN if infinite)     */
/*      fc              how large fwd may be (MAX_FULL_LEN if infinite)      */
/*      bfc             how large back + fwd may be (MAX_FULL_LEN if inf.)   */
/*                                                                           */
/*                                                                           */
/*  Here now is the list of all object types, what they represent, and       */
/*  what fields they contain.  The list also indicates what children each    */
/*  object of the given type can expect to have.                             */
/*                                                                           */
/*  LINK - one link in the directed acyclic graph which is Lout's universal  */
/*         internal data structure.  All the other types below are various   */
/*         types of nodes.  Has ALL only (and no fpos) except see CROSS_SYM  */
/*                                                                           */
/*  GAP_OBJ - a gap between two Lout objects                                 */
/*                                                                           */
/*      gap             The gap itself (type GAP)                            */
/*      underline       TRUE if continuous underlining crosses this gap      */
/*      save_*          These fields used by optimum paragraph breaker only  */
/*      first child     If the gap is not just white space, the gap object   */
/*                                                                           */
/*  CLOSURE - an invocation of a user-defined symbol, not yet expanded       */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           After sizing if indefinite (the sizes will be zero)  */
/*      save_style      Style to print this invocation in when expanded      */
/*      actual          The symbol table record defining this symbol         */
/*      threaded        TRUE if symbol lies on a vertical thread             */
/*      external_ver    TRUE if symbol is external in a vertical galley      */
/*      external_hor    TRUE if symbol is external in a horizontal galley    */
/*      children        PAR objects whose children are the actual parameters */
/*                                                                           */
/*  UNDER_REC - a temporary object inserted by FixAndPrintObject to help     */
/*              with working out continuous underlining                      */
/*                                                                           */
/*      back(COLM)      Horizontal position of start of underline            */
/*      fwd(COLM)       Horizontal position of end of underline              */
/*      word_font       Font determining underline appearance                */
/*      word_underline_colour  The colour of the underline                   */
/*      word_texture    The texture of the underline                         */
/*                                                                           */
/*  PAGE_LABEL - a @PageLabel object                                         */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           Indefinite, so all sizes will be zero                */
/*      first child     The parameter of the @PageLabel object               */
/*                                                                           */
/*  NULL_CLOS - a @Null object                                               */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           Indefinite, so all sizes will be zero                */
/*                                                                           */
/*  CROSS, FORCE_CROSS - a cross reference (or forcing cross reference) obj  */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           Indefinite, so all sizes will be zero                */
/*      cross_type      Type of cross reference (preceding, following, etc.) */
/*      children        The two parameters of the cross reference            */
/*                                                                           */
/*  HEAD - the header record for a galley invocation                         */
/*                                                                           */
/*      force_gall      TRUE if this is a forcing galley (i.e. "force into") */
/*      actual          The symbol table record defining this galley         */
/*      enclose_obj     If galley has @Enclose, the enclose object           */
/*      limiter         Helps decide whether to break off or scale if stuck  */
/*      opt_components  If optimizing, the sequence of components            */
/*      opt_constraints If optimizing, the sequence of size constraints      */
/*      opt_counts      If optimizing, the sequence of numbers of components */
/*                      In each child of opt_counts, comp_count has the num  */
/*      opt_comps_permitted number of components left before opt break       */
/*      opt_hyph        If optimizing, whether to hyphenate the galley       */
/*      opt_gazumped    If optimizing, galley has been gazumped recently     */
/*      gall_dir        Promotion direction (COLM for horizontal galleys)    */
/*      ready_galls     Galleys read in from cross reference database        */
/*      must_expand     TRUE if must expand galley object even if indefinite */
/*      sized           TRUE after galley object has been sized              */
/*      foll_or_prec    Direction of search for target (forward, back, etc.) */
/*      whereto         Symbol this galley is targeted at                    */
/*      seen_nojoin     TRUE if // op found within galley anywhere           */
/*      headers[i]      each either nilobj or an ACAT of header components   */
/*      head_next       which header[i] we will use next.                    */
/*                                                                           */
/*  SPLIT - a split object, used for building tables                         */
/*                                                                           */
/*      SIZED           The size of the whole object                         */
/*      first child     An object whose horizontal size is the overall size  */
/*      second child    An object whose vertical size is the overall size    */
/*                                                                           */
/*  PAR - actual parameter of a symbol invocation (always child of CLOSURE)  */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      actual          The symbol table record defining this parameter      */
/*      first child     A Lout object, the value of this parameter           */
/*                                                                           */
/*  WORD, QWORD - a literal word, or a literal word entered in quotes ""     */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the word                                 */
/*      word_font       Font to print this word in (from style)              */
/*      word_colour     Colour to print this word in (from style)            */
/*      word_underline_colour  Colour to print underlines in (from style)    */
/*      word_texture    texture to print this word in (from style)           */
/*      word_outline    If TRUE, print this word in outline (from style)     */
/*      word_language   Language (for hyphenation) of this word (from style) */
/*      word_baselinemark TRUE if mark of this word goes through baseline    */
/*      word_strut      TRUE if this word's char metrics are to be strutted  */
/*      word_ligatures  TRUE if ligatures wanted in this word                */
/*      underline       TRUE if continuous underlining goes under this word  */
/*      word_hyph       Hyphenation wanted for this word (from style)        */
/*      word_save_mark  Coord of column mark, temporarily in FixAndPrint     */
/*      string[]        The characters of the word, null-terminated          */
/*                                                                           */
/*  WORD, QWORD when used as database header records                         */
/*                                                                           */
/*      string[]        Database index file name                             */
/*      reading         TRUE if this database can be read from               */
/*      in_memory       TRUE if this database's index is held in memory      */
/*      db_filep        Pointer to database file (if not in_memory)          */
/*      left_pos        Seek pos of 1st entry in db_filep (if not in_memory) */
/*      db_lines        Pointer to database index lines (if in_memory)       */
/*      db_lineslen     Number of database index lines (if in_memory)        */
/*      first child     List of symbols held in this database                */
/*      other children  CROSS_SYM symbols of symbols in this database        */
/*                      The *links* to these have the following fields:      */
/*                          number   An ID number for this sym in this db    */
/*                          db_targ  TRUE if sym is a galley target          */
/*                                                                           */
/*  WORD, QWORD when used as font records (consult z37.c for more detail)    */
/*                                                                           */
/*      string[]        Font name                                            */
/*      font_num        The number of this font                              */
/*      font_page       Number of most recent page using this font           */
/*      font_size       Size of this font                                    */
/*      font_xheight2   Half-x height of this font                           */
/*      font_bbox_lly   The lly value of the font bounding box               */
/*      font_bbox_ury   The ury value of the font bounding box               */
/*      font_spacewidth Preferred width of space between words in this font  */
/*      font_mapping    The mapping to apply with this font                  */
/*      font_recoded    TRUE if font needs recoding in PostScript output     */
/*                                                                           */
/*  WORD, QWORD when used in hash table to check whether crs defined twice   */
/*                                                                           */
/*      db_checksym     Symbol of the cross reference                        */
/*      string[]        Tag of the cross reference                           */
/*                                                                           */
/*  HSPANNER (VSPANNER) - An object that spans columns (rows)                */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      spanner_broken  TRUE after BreakObject() applied to this object      */
/*      spanner_count   Number of columns (rows) spanned by this spanner     */
/*      spanner_sized   Number of cols (rows) of this spanner sized so far   */
/*      spanner_fixed   Number of cols (rows) of this spanner fixed so far   */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      constraint      Space available for this object as known to MinSize  */
/*      first child     The object that is doing the spanning                */
/*                                                                           */
/*  COL_THR (ROW_THR) - object representing all objects on a col (row) mark  */
/*                                                                           */
/*      SIZED           The horizontal (vertical) size only                  */
/*      thr_state       Tells whether thread is sized or not yet             */
/*      children        The objects on the mark                              */
/*      parents         The parents of the children (one-to-one)             */
/*                                                                           */
/*  ACAT - a paragraph (sequence of objects separated by & or white space)   */
/*                                                                           */
/*      SIZED           The size of the object                               */
/*      save_style      The style to print this paragraph in                 */
/*      children        The paragraph's objects and gaps (obj-gap-obj...obj) */
/*                                                                           */
/*  HCAT (VCAT) - a horizontal (vertical) sequence of objects                */
/*                                                                           */
/*      SIZED           The size of the object                               */
/*      save_style      The style to print this object in                    */
/*      children        The objects and gaps (obj-gap-obj...obj)             */
/*      adjust_cat      Whether to perform adjustment (@VAdjust, etc.)       */
/*                                                                           */
/*  WIDE (HIGH) - @Wide (@High) object                                       */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      constraint      The horizontal (vertical) size constraint            */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  HSHIFT (VSHIFT) - @HShift (@VShift) object                               */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      shift_type      left, right etc.                                     */
/*      shift_gap       The amount to shift                                  */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  HMIRROR (VMIRROR) - @HMirror (@VMirror) object                           */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  HSCALE (VSCALE) - @HScale (@VScale) object                               */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      constraint      used temporarily by FixAndPrintObject                */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  SCALE - @Scale object                                                    */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      bc(constraint)  The horizontal scale factor                          */
/*      fc(constraint)  The vertical scale factor                            */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      vert_sized      TRUE if vertical size of object is known             */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  BEGIN_HEADER, SET_HEADER - @BeginHeaderComponent, @SetHeaderComponent    */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object (will be 0)                   */
/*      first child     The gap for after this header (before manifesting)   */
/*      last child      The right parameter of this symbol                   */
/*                                                                           */
/*  END_HEADER, CLEAR_HEADER - @EndHeaderComponent, @ClearHeaderComponent    */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object (will be 0)                   */
/*                                                                           */
/*  ONE_COL (ONE_ROW) - @OneCol (@OneRow) object                             */
/*  HCOVER (VCOVER) - @HCover (@VCover) object                               */
/*  HCONTRACT (VCONTRACT) - @HContract (@VContract) object                   */
/*  HEXPAND (VEXPAND) - @HExpand (@VExpand) object                           */
/*  START_HSPAN, START_VSPAN - @StartHSpan, @StartVSpan                      */
/*  START_HVSPAN - @StartHVSpan                                              */
/*  HSPAN (VSPAN) - @HSpan (@VSpan) symbols                                  */
/*  KERN_SHRINK - @KernShrink object                                         */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      first child     The right parameter of this symbol (if any)          */
/*                                                                           */
/*  PADJUST (HADJUST, VADJUST) - @PAdjust (@HAdjust, @VAdjust) symbols       */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  ROTATE - @Rotate symbol                                                  */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      sparec(cons)    Amount to rotate by (after manifesting)              */
/*      first child     Amount to rotate by (before manifesting)             */
/*      last child      The right parameter of this symbol                   */
/*                                                                           */
/*  BACKGROUND - @Background symbol                                          */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      children        The two parameters of this symbol                    */
/*                                                                           */
/*  GRAPHIC, PLAIN_GRAPHIC - @Graphic, @PlainGraphic symbols                 */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      children        The two parameters of this symbol                    */
/*                                                                           */
/*  LINK_SOURCE, LINK_DEST, LINK_URL - @LinkSource, @LinkDest, @URLLink      */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      children        The two parameters of this symbol                    */
/*                                                                           */
/*  CASE - @Case symbol                                                      */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      first child     The left parameter of @Case                          */
/*      last child      The right parameter (sequence of @Yield objects)     */
/*                                                                           */
/*  VERBATIM (RAWVERBATIM) - @Verbatim (@RawVerbatim) symbol                 */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      first child     The right parameter of this symbol                   */
/*                                                                           */
/*  FILTERED - object recording filtered Lout object                         */
/*                                                                           */
/*      filter_use_begin TRUE if filter enclosed in @Begin ... @End          */
/*      filter_actual   The symbol this is an invocation of                  */
/*      first child     WORD containing file name of filter input file       */
/*      second child    WORD containing file name of filter output file      */
/*      last child      Scope snapshot for reading filter output file        */
/*                                                                           */
/*  XCHAR - @Char symbol                                                     */
/*  NEXT - @Next symbol                                                      */
/*  ONE_OF - @OneOf symbol                                                   */
/*  UNDERLINE - @Underline symbol                                            */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      last child      The right parameter of this symbol                   */
/*                                                                           */
/*  FONT, SPACE, BREAK - @Font, @Space, @Break symbols                       */
/*  YUNIT, ZUNIT - @YUnit, @ZUnit symbols                                    */
/*  COLOUR, UNDERLINE_COLOUR, TEXTURE - @SetColour, @SetUnderlineColour      */
/*  TEXTURE - @SetTexture                                                    */
/*  OUTLINE, LANGUAGE - @Outline, @Language symbols                          */
/*  PLUS, MINUS, - @Plus, @Minus symbols                                     */
/*  MELD, COMMON, RUMP, INSERT - @Meld, @Common, @Rump, @Insert symbols      */
/*  OPEN, TAGGED - @Open, @Tagged symbols                                    */
/*  YIELD - @Yield symbol                                                    */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      first child     The left parameter of this symbol                    */
/*      last child      The right parameter of this symbol                   */
/*                                                                           */
/*  ENV_OBJ - a Lout object with environment attached                        */
/*                                                                           */
/*      first child     The Lout object                                      */
/*      last child      Its environment (ENV object)                         */
/*                                                                           */
/*  ENV - environment of some Lout object                                    */
/*                                                                           */
/*      children        Components of the environment                        */
/*                                                                           */
/*  INCGRAPHIC, SINCGRAPHIC - @IncludeGraphic, @SysIncludeGraphic symbols    */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      SIZED           The size of the object                               */
/*      save_mark       used temporarily by FixAndPrintObject                */
/*      incgraphic_ok   TRUE if file name pans out OK                        */
/*      last child      The right parameter of this symbol                   */
/*                                                                           */
/*  TSPACE, TJUXTA - tokens representing white space                         */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      mark(gap)       FALSE                                                */
/*      join(gap)       TRUE                                                 */
/*                                                                           */
/*  BEGIN - @Begin symbol                                                    */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*      actual          Symbol this @Begin starts parameter of               */
/*                                                                           */
/*  END - @End symbol                                                        */
/*  LBR, RBR - tokens representing left brace and right brace                */
/*  USE, NOT_REVEALED - @Use, @NotRevealed symbols                           */
/*  GSTUB_EXT, GSTUB_INT, GSTUB_NONE - stubs for transferred galleys         */
/*  UNEXPECTED_EOF - unexpected end of file token                            */
/*  INCLUDE, SYS_INCLUDE - @Include, @SysInclude symbols                     */
/*  INCG_REPEATED, SINCG_REPEATED -                                          */
/*    @IncludeGraphicRepeated, @SysIncludeGraphicRepeated symbols            */
/*  PREPEND, SYS_PREPEND - @PrependGraphic, @SysPrependGraphic symbols       */
/*  ENVA, ENVB, ENVC, ENVD - @LEnvA, @LEnvB, @LEnvC, @LEnvD tokens only      */
/*  CENV, CLOS, LVIS, LUSE, LEO - @LCEnv, @LClos, @LVis, @LUse, @LEO tokens  */
/*  BACKEND - @BackEnd symbol                                                */
/*  CURR_LANG, CURR_FAMILY, CURR_FACE - @CurrLang, @CurrFamily, @CurrFace    */
/*  CURR_YUNIT, CURR_ZUNIT - @CurrYUnit, @CurrZUnit                          */
/*                                                                           */
/*      TOKEN           While still being parsed                             */
/*                                                                           */
/*  DEAD - the index of a dead galley                                        */
/*                                                                           */
/*  UNATTACHED - the index of an unattached galley                           */
/*                                                                           */
/*      actual          The galley referred to                               */
/*      non_blocking    TRUE if this index should not block galley flushing  */
/*      blocked         TRUE if this index is now blocking galley flushing   */
/*      pinpoint        Exact anchor point of this index                     */
/*                                                                           */
/*  RECEPTIVE, RECEIVING - the index of a receptive or receiving object      */
/*                                                                           */
/*      actual          The object (symbol invocation) referred to           */
/*      trigger_externs TRUE is this index's galley has external galleys     */
/*      non_blocking    TRUE if this index should not block galley flushing  */
/*      blocked         TRUE if this index is now blocking galley flushing   */
/*                                                                           */
/*  RECURSIVE - the index of a recursive but definite object                 */
/*                                                                           */
/*      actual          The recursive symbol invocation referred to          */
/*                                                                           */
/*  PRECEDES - an index recording a precedes/follows flushing constraint     */
/*                                                                           */
/*      first child     Other parent of this is the corresponding FOLLOWS    */
/*                                                                           */
/*  FOLLOWS - an index recording a precedes/follows flushing constraint      */
/*                                                                           */
/*      blocked         TRUE if this index is now blocking galley flushing   */
/*      first child     Other parent of this is the corresponding PRECEDES   */
/*                                                                           */
/*  CROSS_LIT - not actually an object at all                                */
/*                                                                           */
/*  CROSS_PREC, CROSS_FOLL, CROSS_FOLL_OR_PREC - the index of a cross ref    */
/*                                                                           */
/*      actual          The cross reference referred to                      */
/*      underline       TRUE if continuous underline goes through here       */
/*      first child     Equal to actual                                      */
/*                                                                           */
/*  GALL_PREC, GALL_FOLL, GALL_FOLL_OR_PREC - index of a galley              */
/*                                                                           */
/*      actual          The galley referred to                               */
/*      underline       TRUE if continuous underline goes through here       */
/*      pinpoint        Exact anchor point of this index                     */
/*                                                                           */
/*  GALL_TARG - index of the target of a galley                              */
/*                                                                           */
/*      actual          The galley target (symbol invocation) referred to    */
/*      underline       TRUE if continuous underline goes through here       */
/*                                                                           */
/*  PAGE_LABEL_IND - the index of a @PageLabel object                        */
/*                                                                           */
/*      actual          The @PageLabel object referred to                    */
/*      underline       TRUE if continuous underline goes through here       */
/*      first child     Equal to actual                                      */
/*                                                                           */
/*  SCALE_IND - the index of a @Scale symbol with empty left parameter       */
/*  COVER_IND - the index of an @HCover or @VCover object                    */
/*  EXPAND_IND - the index of an @HExpand or @VExpand object                 */
/*                                                                           */
/*      actual          The object referred to                               */
/*      underline       TRUE if continuous underline goes through here       */
/*                                                                           */
/*  THREAD - a sequence of threads (basically local to Manifest)             */
/*                                                                           */
/*      children        The threads                                          */
/*                                                                           */
/*  CROSS_SYM - a record of the cross reference state of some symbol         */
/*                                                                           */
/*      target_state    Whether we currently have a preceding target         */
/*      target_file     Which file target is written to                      */
/*      target_val      Value of target (if target_state == SEEN_TARGET)     */
/*      target_seq      A sequence number                                    */
/*      target_pos      Seek position of target in target_file               */
/*      target_lnum     Line number of target in target_file                 */
/*      gall_seq        Sequence number for galleys targeted to here         */
/*      symb            The symbol table record of the symbol this is for    */
/*      gall_tag        I forget!                                            */
/*      gall_tfile      The most recent cr database file for this sym        */
/*      children        Cross references and galleys waiting for a target    */
/*                      These children have the following fields:            */
/*                                                                           */
/*                          string[]   The sequence number                   */
/*                          cs_type    The cross reference type              */
/*                          cs_fnum    File number where value written       */
/*                          cs_pos     File seek position                    */
/*                          cs_lnum    File line number                      */
/*                                                                           */
/*  CR_ROOT - all CROSS_SYM objects are children of this singleton           */
/*                                                                           */
/*      children        All CROSS_SYM symbols                                */
/*                                                                           */
/*  MACRO - a symbol table entry for a symbol which is a macro               */
/*  LOCAL - a symbol table entry for a symbol which is a local symbol        */
/*  LPAR - a symbol table entry for a symbol which is a left parameter       */
/*  RPAR - a symbol table entry for a symbol which is a right parameter      */
/*  NPAR - a symbol table entry for a symbol which is a named parameter      */
/*                                                                           */
/*      enclosing       The symbol that this one is defined within, if any   */
/*      sym_body        The symbol body (token sequence if MACRO)            */
/*      base_uses       Local to symbol table, for calculating call graph    */
/*      uses            Call graph info                                      */
/*      marker          For call graph calculation                           */
/*      imports         The import list preceding this symbol, if any        */
/*      filter          Child @Filter symbol, if any                         */
/*      use_invocation  A @Use clause containing this symbol, if any         */
/*      predefined      If predefined symbol, its non-zero enum code         */
/*      has_compulsory  Number of parameters with "compulsory" tag           */
/*      uses_count      Number of times this symbol is used                  */
/*      npar_code       One-letter abbreviation for this NPAR                */
/*      cross_sym       The CROSS_SYM record for this symbol, if any         */
/*      recursive       TRUE if symbol is recursive                          */
/*      has_body        TRUE if symbol has a body parameter                  */
/*      imports_encl    TRUE if symbol imports the symbol enclosing itself   */
/*      right_assoc     TRUE if this symbol has "associativity right"        */
/*      precedence      The precedence of this symbol                        */
/*      indefinite      TRUE if this symbol is indefinite (e.g. receptive)   */
/*      recursive       TRUE if symbol is recursive                          */
/*      is_extern_target   TRUE if symbol is the target of external galley   */
/*      uses_extern_target TRUE if symbol uses target of an external galley  */
/*      visible         TRUE if symbol is exported                           */
/*      uses_galley     TRUE if symbol uses a galley                         */
/*      horiz_galley    if galley, ROWM if vertical, COLM if horizontal      */
/*      is_compulsory   TRUE if this is a parameter with "compulsory" tag    */
/*      dirty           TRUE if must copy this parameter, not link it        */
/*      has_par         TRUE if this symbol has at least one parameter       */
/*      has_lpar        TRUE if this symbol has a left parameter             */
/*      has_rpar        TRUE if this symbol has a right or body parameter    */
/*      has_target      TRUE if this symbol has a target (is a galley)       */
/*      force_target    TRUE if this symbol has a forcing target             */
/*      is_target       TRUE if this symbol is @Target, defining a target    */
/*      has_tag         TRUE if this symbol has a @Tag parameter             */
/*      is_tag          TRUE if this symbol is a @Tag parameter              */
/*      has_key         TRUE if this symbol has a @Key parameter             */
/*      is_key          TRUE if this symbol is a @Key parameter              */
/*      has_optimize    TRUE if this symbol has an @Optimize parameter       */
/*      is_optimize     TRUE if this symbol is an @Optimize parameter        */
/*      has_merge       TRUE if this symbol has a @Merge parameter           */
/*      is_merge        TRUE if this symbol is a @Merge parameter            */
/*      has_enclose     TRUE if this symbol has an @Enclose parameter        */
/*      is_enclose      TRUE if this symbol is an @Enclose parameter         */
/*                                                                           */
/*  EXT_GALL - a record of an external galley, not actually read in yet      */
/*                                                                           */
/*      eg_fnum         Number of file read from                             */
/*      eg_fpos         Position in that file                                */
/*      eg_lnum         Line number in that file                             */
/*      eg_cont         Continuation (where to look for next galley)         */
/*      eg_symbol       The symbol that is the target of this galley         */
/*      first child     The galley tag                                       */
/*      second child    The galley sequence string                           */
/*                                                                           */
/*  CR_LIST - a list of cross references                                     */
/*                                                                           */
/*      children        The cross-references                                 */
/*                                                                           */
/*  SCOPE_SNAPSHOT - a snapshot of one element of the current scope stack    */
/*                                                                           */
/*      ss_npars_only   Value of npars_only in this element                  */
/*      ss_vis_only     Value of vis_only in this element                    */
/*      ss_body_ok      Value of body_ok in this element                     */
/*      ss_suppress     Value of suppress_visible in this element            */
/*                                                                           */
/*  DISPOSED - a disposed object (available for reallocation)                */
/*                                                                           */
/*****************************************************************************/

typedef union rec
{
  struct word_type	/* all fields of WORD and QWORD, token and object */
  {  LIST		olist[2];
     FIRST_UNION	ou1;
     SECOND_UNION	ou2;
     THIRD_UNION	ou3;
     FULL_CHAR		ostring[4];
  } os1;

  struct closure_type	/* all fields of CLOSURE, both as token and object */
  {  LIST		olist[2];
     FIRST_UNION	ou1;
     SECOND_UNION	ou2;
     THIRD_UNION	ou3;
     FOURTH_UNION	ou4;
     union rec		*oactual;
     union
     { union rec *owhereto;
       union rec *opinpoint;
       FULL_LENGTH    osave_mark;
     } oux;
  } os2;
  
  struct head_type	/* all fields of HEAD, both as token and object */
  {  LIST		olist[2];
     FIRST_UNION	ou1;
     SECOND_UNION	ou2;
     THIRD_UNION	ou3;
     FOURTH_UNION	ou4;
     union rec		*oactual;
     union
     { union rec *owhereto;
       union rec *opinpoint;
       FULL_LENGTH    osave_mark;
     } oux;
     union rec *oready_galls;
     union rec *oopt_components;
     union rec *oopt_constraints;
     union rec *oopt_counts;
     union rec *olimiter;
     union rec *oenclose_obj;
     union rec *oheaders[MAX_HCOPIES];
     int	ohead_next;
     int        oopt_comps_permitted;
  } os2a;
  
  struct object_type	/* the general OBJECT */
  {  LIST		olist[2];
     FIRST_UNION	ou1;
     SECOND_UNION	ou2;
     THIRD_UNION	ou3;
     FOURTH_UNION	ou4;
  } os3;

  struct link_type	/* LINK */
  {  LIST		olist[2];
     unsigned char	otype;
     unsigned char	onumber;
     unsigned char	odb_targ;
  } os4;
  
  struct gapobj_type	/* GAP_OBJ */
  {  LIST		olist[2];
     FIRST_UNION	ou1;
     SECOND_UNION	ou2;
     GAP		ogap;
     int		osave_badness;		/* optimum paragraph breaker */
     FULL_LENGTH	osave_space;		/* optimum paragraph breaker */
     FULL_LENGTH	osave_actual_gap;	/* optimum paragraph breaker */
     union rec  	*osave_prev;		/* optimum paragraph breaker */
     union rec  	*osave_cwid;		/* optimum paragraph breaker */
  } os5;

  struct symbol_type
  {  LIST		olist[2];
     FIRST_UNION	ou1;
     SECOND_UNION	ou2;
     union rec		*oenclosing;
     union rec		*osym_body;
     union rec		*obase_uses;
     union rec		*ouses;
     union rec		*omarker;
     union rec		*ocross_sym;
     union rec		*oimports;
     union rec		*ofilter;
     union rec		*ouse_invocation;
     unsigned short 	opredefined;
     unsigned short 	ohas_compulsory;
     unsigned char	ouses_count;
     unsigned char	onpar_code;
     BOOLEAN		ois_optimize	     : 1;
     BOOLEAN		ohas_optimize	     : 1;
     BOOLEAN		ois_merge	     : 1;
     BOOLEAN		ohas_merge	     : 1;
     BOOLEAN		ois_enclose	     : 1;
     BOOLEAN		ohas_enclose	     : 1;
     BOOLEAN		ois_compulsory	     : 1;
  } os6;

  struct cr_type
  {  LIST		olist[2];
     unsigned char	otype;
     unsigned char	otarget_state;
     FILE_NUM		otarget_file;
     union rec		*otarget_val;
     int		otarget_seq;
     int		otarget_pos;
     int		otarget_lnum;
     int		ogall_seq;
     union rec		*osymb;
     union rec		*ogall_tag;
     FILE_NUM		ogall_tfile;
  } os7;

  struct ext_gall_type
  {  LIST		olist[2];
     unsigned char	otype;
     FILE_NUM		oeg_fnum;
     int		oeg_lnum;
     long		oeg_fpos;
     long		oeg_cont;
     union rec		*oeg_symbol;
  } os8;

  struct uses_type
  {  union rec	*oitem;
     union rec	*onext;
  } os9;
#define	USES_SIZE ceiling( sizeof(struct uses_type), sizeof(ALIGN) )

  struct hash_entry_type
  {  LIST	olist[1];
  } os10;

} *OBJECT;


/*@::macros for fields of OBJECT@*********************************************/
/*                                                                           */
/*  Macros for fields of OBJECT.                                             */
/*                                                                           */
/*****************************************************************************/

#define	succ(x, dim)		(x)->os1.olist[dim].osucc
#define	pred(x, dim)		(x)->os1.olist[dim].opred

#define type(x)			(x)->os1.ou1.os11.otype
#define	rec_size(x)		(x)->os1.ou1.os11.orec_size
#define font_bbox_lly(x)	(x)->os1.ou2.os25.ofont_bbox_lly
#define font_bbox_ury(x)	(x)->os1.ou2.os25.ofont_bbox_ury
#define	precedence(x)		(x)->os1.ou2.os21.oprecedence
#define	hspace(x)		(x)->os1.ou2.os21.ohspace
#define	vspace(x)		(x)->os1.ou2.os21.ovspace

#define	word_font(x)		(x)->os1.ou2.os22.oword_font
#define spanner_count(x)	word_font(x)
#define incg_type(x)		word_font(x)
#define	word_colour(x)		(x)->os1.ou2.os22.oword_colour
#define	word_underline_colour(x) (x)->os1.ou2.os22.oword_underline_colour
#define	word_texture(x)		(x)->os1.ou2.os22.oword_texture
#define spanner_sized(x)	word_colour(x)
#define	word_outline(x)		(x)->os1.ou2.os22.oword_outline
#define	word_language(x)	(x)->os1.ou2.os22.oword_language
#define	word_baselinemark(x)	(x)->os1.ou2.os22.oword_baselinemark
#define	word_strut(x)		(x)->os1.ou2.os22.oword_strut
#define	word_ligatures(x)	(x)->os1.ou2.os22.oword_ligatures
#define	spanner_fixed(x)	word_language(x)
#define	spanner_broken(x)	word_outline(x)
#define	underline(x)		(x)->os1.ou2.os22.ounderline
#define	word_hyph(x)		(x)->os1.ou2.os22.oword_hyph
#define	filter_use_begin(x)	(x)->os1.ou2.os22.oword_colour

#define	ss_npars_only(x)	word_font(x)
#define	ss_vis_only(x)		word_colour(x)
#define	ss_body_ok(x)		word_outline(x)
#define	ss_suppress(x)		word_language(x)

#define	non_blocking(x)		(x)->os1.ou2.os23.onon_blocking
#define	vert_sized(x)		non_blocking(x)
#define	sized(x)		(x)->os1.ou2.os23.osized
#define	threaded(x)		(x)->os1.ou2.os23.othreaded
#define	external_ver(x)		(x)->os1.ou2.os23.oexternal_ver
#define	external_hor(x)		(x)->os1.ou2.os23.oexternal_hor
#define	blocked(x)		(x)->os1.ou2.os23.oblocked
#define	seen_nojoin(x)		blocked(x)
#define	trigger_externs(x)	(x)->os1.ou2.os23.otrigger_ext
#define	must_expand(x)		(x)->os1.ou2.os23.omust_expand
#define	gall_dir(x)		(x)->os1.ou2.os23.ogall_dir
#define	opt_hyph(x)		(x)->os1.ou2.os23.oopt_hyph
#define	opt_gazumped(x)		(x)->os1.ou2.os23.oopt_gazumped
#define	adjust_cat(x)		(x)->os1.ou2.os23.oadjust_cat
#define	force_gall(x)		(x)->os1.ou2.os23.oforce_gall
#define	cross_type(x)		(x)->os1.ou2.os23.ocross_type
#define	foll_or_prec(x)		(x)->os1.ou2.os23.ofoll_or_prec
#define	thr_state(x)		cross_type(x)
#define	incgraphic_ok(x)	cross_type(x)

#define	left_pos(x)		(x)->os1.ou2.os24.oleft_pos
#define	db_lineslen(x)		left_pos(x)
#define	reading(x)		(x)->os1.ou2.os24.oreading
#define	in_memory(x)		(x)->os1.ou2.os24.oin_memory

#define	is_tag(x)		(x)->os1.ou2.os26.ois_tag
#define	has_tag(x)		(x)->os1.ou2.os26.ohas_tag
#define	has_lpar(x)		(x)->os1.ou2.os26.ohas_lpar
#define	has_rpar(x)		(x)->os1.ou2.os26.ohas_rpar
#define	right_assoc(x)		(x)->os1.ou2.os26.oright_assoc
#define	is_target(x)		(x)->os1.ou2.os26.ois_target
#define	has_target(x)		(x)->os1.ou2.os26.ohas_target
#define	force_target(x)		(x)->os1.ou2.os26.oforce_target
#define	has_body(x)		(x)->os1.ou2.os26.ohas_body
#define	indefinite(x)		(x)->os1.ou2.os26.oindefinite
#define	recursive(x)		(x)->os1.ou2.os26.orecursive
#define	uses_extern_target(x)	(x)->os1.ou2.os26.ouses_extern_target
#define	is_extern_target(x)	(x)->os1.ou2.os26.ois_extern_target
#define	is_key(x)		(x)->os1.ou2.os26.ois_key
#define	has_key(x)		(x)->os1.ou2.os26.ohas_key
#define	dirty(x)		(x)->os1.ou2.os26.odirty
#define	visible(x)		(x)->os1.ou2.os26.ovisible
#define	has_mark(x)		(x)->os1.ou2.os26.ohas_mark
#define	has_join(x)		(x)->os1.ou2.os26.ohas_join
#define	has_par(x)		(x)->os1.ou2.os26.ohas_par
#define	uses_galley(x)		(x)->os1.ou2.os26.ouses_galley
#define	horiz_galley(x)		(x)->os1.ou2.os26.ohoriz_galley
#define	imports_encl(x)		(x)->os1.ou2.os26.oimports_encl

#define	fpos(x)			(x)->os1.ou1.ofpos
#define word_save_mark(x)	(x)->os1.ou1.os11.oword_save_mark

#define	back(x, dim)		(x)->os1.ou3.os31.oback[dim]
#define	comp_count(x)		back(x, COLM)
#define	fwd(x, dim)		(x)->os1.ou3.os31.ofwd[dim]
#define	size(x, dim)		(back(x, dim) + fwd(x, dim))
#define	db_filep(x)		(x)->os1.ou3.odb_filep
#define	db_lines(x)		(x)->os1.ou3.odb_lines
#define	filter_actual(x)	(x)->os1.ou3.ofilter_actual
#define	db_checksym(x)		filter_actual(x)

#define	cs_type(x)		(x)->os1.ou3.os33.ocs_type
#define	cs_fnum(x)		(x)->os1.ou3.os33.ocs_fnum
#define	cs_pos(x)		(x)->os1.ou3.os33.ocs_pos
#define	cs_lnum(x)		(x)->os1.ou3.os33.ocs_lnum

#define line_count(x)		(x)->os1.ou3.os34.oline_count
#define file_number(x)		(x)->os1.ou3.os34.ofile_number
#define type_of_file(x)		(x)->os1.ou3.os34.otype_of_file
#define used_suffix(x)		(x)->os1.ou3.os34.oused_suffix
#define updated(x)		(x)->os1.ou3.os34.oupdated
#define path(x)			(x)->os1.ou3.os34.opath

#define string(x)		(x)->os1.ostring

#define	save_style(x)		(x)->os2.ou4.osave_style
#define	constraint(x)		(x)->os2.ou4.oconstraint
#define	shift_type(x)		width(space_gap(save_style(x)))
#define	shift_gap(x)		line_gap(save_style(x))

#define actual(x)		(x)->os2.oactual
#define whereto(x)		(x)->os2.oux.owhereto
#define pinpoint(x)		(x)->os2.oux.opinpoint
#define save_mark(x)		(x)->os2.oux.osave_mark
#define ready_galls(x)		(x)->os2a.oready_galls
#define opt_components(x)	(x)->os2a.oopt_components
#define opt_constraints(x)	(x)->os2a.oopt_constraints
#define opt_counts(x)		(x)->os2a.oopt_counts
#define limiter(x)		(x)->os2a.olimiter
#define enclose_obj(x)		(x)->os2a.oenclose_obj
#define headers(x, i)		(x)->os2a.oheaders[i]
#define head_next(x)		(x)->os2a.ohead_next
#define opt_comps_permitted(x)	(x)->os2a.oopt_comps_permitted

#define	number(x)		(x)->os4.onumber
#define	db_targ(x)		(x)->os4.odb_targ

#define	gap(x)			(x)->os5.ogap
#define	save_badness(x)		(x)->os5.osave_badness
#define	save_space(x)		(x)->os5.osave_space
#define	save_actual_gap(x)	(x)->os5.osave_actual_gap
#define	save_prev(x)		(x)->os5.osave_prev
#define	save_cwid(x)		(x)->os5.osave_cwid

#define	enclosing(x)		(x)->os6.oenclosing
#define	sym_body(x)		(x)->os6.osym_body
#define	base_uses(x)		(x)->os6.obase_uses
#define	uses(x)			(x)->os6.ouses
#define	marker(x)		(x)->os6.omarker
#define	cross_sym(x)		(x)->os6.ocross_sym
#define	imports(x)		(x)->os6.oimports
#define	filter(x)		(x)->os6.ofilter
#define	use_invocation(x)	(x)->os6.ouse_invocation
#define	predefined(x)		(x)->os6.opredefined
#define	has_compulsory(x)	(x)->os6.ohas_compulsory
#define	uses_count(x)		(x)->os6.ouses_count
#define	npar_code(x)		(x)->os6.onpar_code
#define	is_optimize(x)		(x)->os6.ois_optimize
#define	has_optimize(x)		(x)->os6.ohas_optimize
#define	is_merge(x)		(x)->os6.ois_merge
#define	has_merge(x)		(x)->os6.ohas_merge
#define	is_enclose(x)		(x)->os6.ois_enclose
#define	has_enclose(x)		(x)->os6.ohas_enclose
#define	is_compulsory(x)	(x)->os6.ois_compulsory

#define	target_state(x)		(x)->os7.otarget_state
#define	target_file(x)		(x)->os7.otarget_file
/* #define cr_file(x)		(x)->os7.ocr_file unused */
#define	target_val(x)		(x)->os7.otarget_val
#define	target_seq(x)		(x)->os7.otarget_seq
#define	target_pos(x)		(x)->os7.otarget_pos
#define	target_lnum(x)		(x)->os7.otarget_lnum
/* #define cr_seq(x)		(x)->os7.ocr_seq unused */
#define	gall_seq(x)		(x)->os7.ogall_seq
#define	symb(x)			(x)->os7.osymb
#define	gall_tag(x)		(x)->os7.ogall_tag
#define	gall_tfile(x)		(x)->os7.ogall_tfile

#define	eg_fnum(x)		(x)->os8.oeg_fnum
#define	eg_fpos(x)		(x)->os8.oeg_fpos
#define	eg_lnum(x)		(x)->os8.oeg_lnum
#define	eg_cont(x)		(x)->os8.oeg_cont
#define	eg_symbol(x)		(x)->os8.oeg_symbol

#define	item(x)			(x)->os9.oitem
#define	next(x)			(x)->os9.onext

#define	font_num(x)		(x)->os1.ou3.os32.ofont_num
#define	font_page(x)		(x)->os1.ou3.os32.ofont_page
#define	font_size(x)		(x)->os1.ou3.os32.ofont_size
#define	font_xheight2(x)	(x)->os1.ou3.os32.ofont_xheight2
#define	font_spacewidth(x)	(x)->os1.ou3.os32.ofont_spacewidth
#define	font_mapping(x)		(x)->os1.ou3.os32.ofont_mapping
#define	font_recoded(x)		(x)->os1.ou3.os32.ofont_recoded


/*@::FONT_INFO@***************************************************************/
/*                                                                           */
/*  typedef FONT_INFO - information about font metrics etc.  Really private  */
/*  but shared between z37.c and z24.c                                       */
/*                                                                           */
/*****************************************************************************/

struct metrics {
  FULL_LENGTH up;
  FULL_LENGTH down;
  FULL_LENGTH left;
  FULL_LENGTH right;
  FULL_LENGTH last_adjust;
};

typedef struct composite_rec {
  FULL_CHAR char_code;
  FULL_LENGTH x_offset;
  FULL_LENGTH y_offset;
} COMPOSITE;

typedef struct font_rec {
  struct metrics	*size_table;		/* metrics of sized fonts    */
  FULL_CHAR		*lig_table;		/* ligatures                 */
  unsigned short	*composite;		/* non-zero means composite  */
  COMPOSITE		*cmp_table;		/* composites to build	     */
  int			cmp_top;		/* length of cmp_table	     */
  OBJECT		font_table;		/* record of sized fonts     */
  OBJECT		original_face;		/* face object of this font  */
  FULL_LENGTH		underline_pos;		/* position of underline     */
  FULL_LENGTH		underline_thick;	/* thickness of underline    */
  unsigned short	*kern_table;		/* first kerning chars       */
  FULL_CHAR		*kern_chars;		/* second kerning chars      */
  unsigned char		*kern_value;		/* points into kern_lengths  */
  FULL_LENGTH		*kern_sizes;		/* sizes of kernings         */
} FONT_INFO;


/*@::MAP_VEC@*****************************************************************/
/*                                                                           */
/*  typedef MAP_VEC - information about character mappings.  Really private  */
/*  to z38.c but (for efficiency) shared with z37.c and z24.c                */
/*                                                                           */
/*****************************************************************************/

#define MAX_CHASH       353             /* size of hash table                */
#define MAP_UPPERCASE     0             /* the map to upper case             */
#define MAP_LOWERCASE     1             /* the map to lower case             */
#define MAP_UNACCENTED    2             /* the map to unaccented             */
#define MAP_ACCENT        3             /* the map to the accent character   */
#define MAPS              4             /* the number of maps in each file   */
 
typedef struct mapvec {
  OBJECT        file_name;              /* name of file containing the vec   */
  FILE_NUM      fnum;                   /* the file number of this file      */
  BOOLEAN       seen_recoded;           /* TRUE if a font recode was seen    */
  int		last_page_printed;	/* most recent page on which printed */
  OBJECT        name;                   /* PostScript name of encoding vec   */
  OBJECT        vector[MAX_CHARS];      /* character names                   */
  FULL_CHAR     hash_table[MAX_CHASH];  /* character hash table for inverse  */
  FULL_CHAR     map[MAPS][MAX_CHARS];   /* the mappings                      */
} *MAP_VEC;


/*@::BACK_END@****************************************************************/
/*                                                                           */
/*  typedef BACK_END - an OO-like record describing one back end             */
/*                                                                           */
/*****************************************************************************/

typedef struct back_end_rec {
  int code;				/* the code number of the back end   */
  FULL_CHAR *name;			/* string name of the back end	     */
  BOOLEAN scale_avail;			/* TRUE if @Scale is available	     */
  BOOLEAN rotate_avail;			/* TRUE if @Rotate is available	     */
  BOOLEAN mirror_avail;			/* TRUE if @HMirror, @VMirror avail  */
  BOOLEAN graphic_avail;		/* TRUE if @Graphic is available     */
  BOOLEAN incgraphic_avail;		/* TRUE if @IncludeGraphic is avail. */
  BOOLEAN plaingraphic_avail;		/* TRUE if @PlainGraphic is avail.   */
  BOOLEAN fractional_spacing_avail;	/* TRUE if fractional spacing avail. */
  BOOLEAN uses_font_metrics;		/* TRUE if actual font metrics used  */
  BOOLEAN colour_avail;			/* TRUE if colour is available       */
  void (*PrintInitialize)(FILE *fp, BOOLEAN encapsulated);
  void (*PrintLength)(FULL_CHAR *buff, int length, int length_dim);
  void (*PrintPageSetupForFont)(OBJECT face, int font_curr_page,
    FULL_CHAR *font_name, FULL_CHAR *first_size_str);
  void (*PrintPageResourceForFont)(FULL_CHAR *font_name, BOOLEAN first);
  void (*PrintMapping)(MAPPING m);
  void (*PrintBeforeFirstPage)(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label);
  void (*PrintBetweenPages)(FULL_LENGTH h, FULL_LENGTH v, FULL_CHAR *label);
  void (*PrintAfterLastPage)(void);
  void (*PrintWord)(OBJECT x, int hpos, int vpos);
  void (*PrintPlainGraphic)(OBJECT x, FULL_LENGTH xmk,FULL_LENGTH ymk,OBJECT z);
  void (*PrintUnderline)(FONT_NUM fnum, COLOUR_NUM col, TEXTURE_NUM pat,
    FULL_LENGTH xstart, FULL_LENGTH xstop, FULL_LENGTH ymk);
  void (*CoordTranslate)(FULL_LENGTH xdist, FULL_LENGTH ydist);
  void (*CoordRotate)(FULL_LENGTH amount);
  void (*CoordScale)(float hfactor, float vfactor);
  void (*CoordHMirror)(void);
  void (*CoordVMirror)(void);
  void (*SaveGraphicState)(OBJECT x);
  void (*RestoreGraphicState)(void);
  void (*PrintGraphicObject)(OBJECT x);
  void (*DefineGraphicNames)(OBJECT x);
  void (*SaveTranslateDefineSave)(OBJECT x,FULL_LENGTH xdist,FULL_LENGTH ydist);
  void (*PrintGraphicInclude)(OBJECT x,FULL_LENGTH colmark,FULL_LENGTH rowmark);
  void (*LinkSource)(OBJECT name, FULL_LENGTH llx, FULL_LENGTH lly,
    FULL_LENGTH urx, FULL_LENGTH ury);
  void (*LinkDest)(OBJECT name, FULL_LENGTH llx, FULL_LENGTH lly,
    FULL_LENGTH urx, FULL_LENGTH ury);
  void (*LinkURL)(OBJECT url, FULL_LENGTH llx, FULL_LENGTH lly,
    FULL_LENGTH urx, FULL_LENGTH ury);
  void (*LinkCheck)(void);
} *BACK_END;


/*@::object types@************************************************************/
/*                                                                           */
/*  OBJECT, TOKEN AND OTHER TYPES inhabiting type(x) and predefined(x)       */
/*                                                                           */
/*  Key letters in the adjacent comment indicate where the tag is legal:     */
/*                                                                           */
/*    t  a token type, pushed on token stack                                 */
/*    o  an object type (returned by reduce(), inserted by Manifest)         */
/*    i  an index type (a child of a galley header other than an object)     */
/*    s  a predefined symbol (some symbol table entry has this predefined()) */
/*    n  an indefinite object i.e. one which is ignored in catenation ops    */
/*                                                                           */
/*****************************************************************************/

#define	LINK		     0		/*        a link between objects     */
#define	GAP_OBJ		     1		/*  o     a gap object               */
#define	CLOSURE		     2		/* to  n  a closure of a symbol      */
#define	UNDER_REC	     3		/*  o  n  record of underlining      */
#define	PAGE_LABEL	     4		/* to sn  @PageLabel                 */
#define	NULL_CLOS	     5		/* to sn  @Null                      */
#define	CROSS		     6		/* to sn  && (a cross reference obj) */
#define	FORCE_CROSS	     7		/* to sn  &&& (a forcing cross ref.) */
#define	LINK_DEST_NULL	     8		/* to sn  @LinkDest (null version)   */
#define	HEAD		     9		/*  o  n  a galley header            */
#define	SPLIT		    10		/*  o     @Split                     */
#define	PAR		    11		/*  o     a parameter of a closure   */
#define	WORD		    12		/*  o     a word                     */
#define	QWORD		    13		/*  o     a word (was quoted in i/p) */
#define	HSPANNER	    14		/*  o     a horizontal spanner       */
#define	VSPANNER	    15		/*  o     a vertical spanner         */
#define	ROW_THR		    16		/*  o     a row thread               */
#define	COL_THR		    17		/*  o     a column thread            */
#define	ACAT		    18		/* to s   a sequence of &-ed objs    */
#define	HCAT		    19		/* to s   a sequence of |-ed objs    */
#define	VCAT		    20		/* to s   a sequence of /-ed objs    */
#define	BEGIN_HEADER	    21		/* to s   @BeginHeaderComponent      */
#define	END_HEADER	    22		/* to s   @EndHeaderComponent        */
#define	SET_HEADER	    23		/* to s   @SetHeaderComponent        */
#define	CLEAR_HEADER	    24		/* to s   @ClearHeaderComponent      */
#define	ONE_COL		    25		/* to s   @OneCol                    */
#define	ONE_ROW		    26		/* to s   @OneRow                    */
#define	WIDE		    27		/* to s   @Wide                      */
#define	HIGH		    28		/* to s   @High                      */
#define	HSHIFT		    29		/* to s   @HShift                    */
#define	VSHIFT		    30		/* to s   @VShift                    */
#define	HMIRROR		    31		/* to s   @HScale                    */
#define	VMIRROR		    32		/* to s   @VScale                    */
#define	HSCALE		    33		/* to s   @HScale                    */
#define	VSCALE		    34		/* to s   @VScale                    */
#define	HCOVER		    35		/* to s   @HCover                    */
#define	VCOVER		    36		/* to s   @VCover                    */
#define	SCALE		    37		/* to s   @Scale                     */
#define	KERN_SHRINK	    38		/* to s   @KernShrink                */
#define	HCONTRACT	    39		/* to s   @HContract                 */
#define	VCONTRACT	    40		/* to s   @VContract                 */
#define	HLIMITED	    41		/* to s   @HLimited                  */
#define	VLIMITED	    42		/* to s   @VLimited                  */
#define	HEXPAND		    43		/* to s   @HExpand                   */
#define	VEXPAND		    44		/* to s   @VExpand                   */
#define	START_HSPAN	    45		/* to s   @StartHSpan                */
#define	START_VSPAN 	    46		/* to s   @StartVSpan                */
#define	START_HVSPAN 	    47		/* to s   @StartHVSpan               */
#define	HSPAN  		    48		/* to s   @HSpan                     */
#define	VSPAN  		    49		/* to s   @VSpan                     */
#define	PADJUST		    50		/* to s   @PAdjust                   */
#define	HADJUST		    51		/* to s   @HAdjust                   */
#define	VADJUST		    52		/* to s   @VAdjust                   */
#define	ROTATE		    53		/* to s   @Rotate                    */
#define	BACKGROUND	    54		/* to s   @Background                */
#define	CASE		    55		/* to s   @Case                      */
#define	VERBATIM	    56		/* to s   @Verbatim                  */
#define	RAW_VERBATIM	    57		/* to s   @RawVerbatim               */
#define	YIELD		    58		/* to s   @Yield                     */
#define	BACKEND		    59		/* to s   @BackEnd                   */
#define	FILTERED	    60		/* to s   filtered object (no name)  */
#define	XCHAR		    61		/* to s   @Char                      */
#define	FONT		    62		/* to s   @Font                      */
#define	SPACE		    63		/* to s   @Space                     */
#define	YUNIT		    64		/* to s   @YUnit                     */
#define	ZUNIT		    65		/* to s   @ZUnit                     */
#define	SET_CONTEXT	    66		/* to s   @SetContext                */
#define	GET_CONTEXT	    67		/* to s   @GetContext                */
#define	BREAK		    68		/* to s   @Break                     */
#define	UNDERLINE	    69		/* to s   @Underline                 */
#define	UNDERLINE_COLOUR    70		/* to s   @SetUnderlineColour        */
#define	COLOUR		    71		/* to s   @SetColour and @SetColor   */
#define	TEXTURE		    72		/* to s   @SetTexture                */
#define	OUTLINE		    73		/* to s   @Outline                   */
#define	LANGUAGE	    74		/* to s   @Language                  */
#define	CURR_LANG	    75		/* to s   @CurrLang                  */
#define	CURR_FAMILY	    76		/* to s   @CurrFamily                */
#define	CURR_FACE	    77		/* to s   @CurrFace                  */
#define	CURR_YUNIT	    78		/* to s   @CurrYUnit                 */
#define	CURR_ZUNIT	    79		/* to s   @CurrZUnit                 */
#define	COMMON		    80		/* to s   @Common                    */
#define	RUMP		    81		/* to s   @Rump                      */
#define	MELD		    82		/* to s   @Meld                      */
#define	INSERT		    83		/* to s   @Insert                    */
#define	ONE_OF		    84		/* to s   @OneOf                     */
#define	NEXT		    85		/* to s   @Next                      */
#define	PLUS		    86		/* to s   @Plus                      */
#define	MINUS		    87		/* to s   @Minus                     */
#define	ENV_OBJ		    88		/* to s   object with envt (no name) */
#define	ENV		    89		/* to s   @LEnv                      */
#define	ENVA		    90		/* to s   @LEnvA                     */
#define	ENVB		    91		/* to s   @LEnvB                     */
#define	ENVC		    92		/* to s   @LEnvC                     */
#define	ENVD		    93		/* to s   @LEnvD                     */
#define	CENV		    94		/* to s   @LCEnv                     */
#define	CLOS		    95		/* to s   @LClos                     */
#define	LVIS		    96		/* to s   @LVis                      */
#define	LUSE		    97		/* to s   @LUse                      */
#define	LEO 		    98		/* to s   @LEO                       */
#define	OPEN		    99		/* to s   @Open                      */
#define	TAGGED		   100		/* to s   @Tagged                    */
#define	INCGRAPHIC	   101		/* to s   @IncludeGraphic            */
#define	SINCGRAPHIC	   102		/* to s   @SysIncludeGraphic         */
#define	PLAIN_GRAPHIC	   103		/* to s   @PlainGraphic              */
#define	GRAPHIC		   104		/* to s   @Graphic                   */
#define	LINK_SOURCE	   105		/* to s   @LinkSource                */
#define	LINK_DEST	   106		/* to s   @LinkDest                  */
#define	LINK_URL	   107		/* to s   @URLLink                   */
#define	TSPACE		   108		/* t      a space token, parser only */
#define	TJUXTA		   109		/* t      a juxta token, parser only */
#define	LBR		   110		/* t  s   left brace token           */
#define	RBR		   111		/* t  s   right brace token          */
#define	BEGIN		   112		/* t  s   @Begin token               */
#define	END		   113		/* t  s   @End token                 */
#define	USE		   114		/* t  s   @Use                       */
#define	NOT_REVEALED	   115		/* t  s   @NotRevealed               */
#define	GSTUB_NONE	   116		/* t      a galley stub, no rpar     */
#define	GSTUB_INT	   117		/* t      galley stub internal rpar  */
#define	GSTUB_EXT	   118		/* t      galley stub external rpar  */
#define	UNEXPECTED_EOF	   119		/* t      unexpected end of file     */
#define	INCLUDE		   120		/*    s   @Include                   */
#define	SYS_INCLUDE	   121		/*    s   @SysInclude                */
#define	PREPEND		   122		/*    s   @Prepend                   */
#define	SYS_PREPEND	   123		/*    s   @SysPrepend                */
#define	INCG_REPEATED	   124		/*    s   @IncludeGraphicRepeated    */
#define	SINCG_REPEATED     125		/*    s   @SysIncludeGraphicRepeated */
#define	DATABASE	   126		/*    s   @Database                  */
#define	SYS_DATABASE	   127		/*    s   @SysDatabase               */
#define	DEAD		   128		/*   i    a dead galley              */
#define	UNATTACHED	   129		/*   i    an inner, unsized galley   */
#define	RECEPTIVE	   130		/*   i    a receptive object index   */
#define	RECEIVING	   131		/*   i    a receiving object index   */
#define	RECURSIVE	   132		/*   i    a recursive definite obj.  */
#define	PRECEDES	   133		/*   i    an ordering constraint     */
#define	FOLLOWS		   134		/*   i    other end of ordering c.   */
#define	CROSS_LIT	   135		/*   i    literal word cross-ref     */
#define	CROSS_FOLL	   136		/*   i    following type cross-ref   */
#define	CROSS_FOLL_OR_PREC 137		/*   i    follorprec type cross-ref  */
#define	GALL_FOLL	   138		/*   i    galley with &&following    */
#define	GALL_FOLL_OR_PREC  139		/*   i    galley with &&following    */
#define	CROSS_TARG	   140		/*   i    value of cross-ref         */
#define	GALL_TARG	   141		/*   i    target of these galleys    */
#define	GALL_PREC	   142		/*   i    galley with &&preceding    */
#define	CROSS_PREC	   143		/*   i    preceding type cross-ref   */
#define	PAGE_LABEL_IND	   144		/*   i    index of PAGE_LABEL        */
#define	SCALE_IND	   145		/*   i    index of auto SCALE        */
#define	COVER_IND	   146		/*   i    index of HCOVER or VCOVER  */
#define	EXPAND_IND	   147		/*   i    index of HEXPAND or VEXPD  */
#define	THREAD		   148		/*        a sequence of threads      */
#define	CROSS_SYM	   149		/*        cross-ref info             */
#define	CR_ROOT		   150		/*        RootCross                  */
#define	MACRO	           151		/*        a macro symbol             */
#define	LOCAL	           152		/*        a local symbol             */
#define	LPAR	           153		/*        a left parameter           */
#define	NPAR	           154		/*        a named parameter          */
#define	RPAR	           155		/*        a right parameter          */
#define	EXT_GALL           156		/*        an external galley         */
#define	CR_LIST	           157		/*        a list of cross references */
#define	SCOPE_SNAPSHOT     158		/*        a scope snapshot	     */
#define	DISPOSED           159		/*        a disposed record          */

#define is_indefinite(x)  ((x) >= CLOSURE && (x) <= HEAD)
#define is_header(x)  ((x) >= BEGIN_HEADER && (x) <= CLEAR_HEADER)
#define is_definite(x) 	 ((x) >= SPLIT && (x) <= LINK_URL)
#define	is_par(x)	((x) >= LPAR   && (x) <= RPAR)
#define	is_index(x)	((x) >= DEAD && (x) <= EXPAND_IND)
#define	is_type(x)	((x) >= LINK && (x) < DISPOSED)
#define	is_word(x)	((x) == WORD || (x) == QWORD)
#define	is_cross(x)	((x) == CROSS || (x) == FORCE_CROSS)
#define is_cat_op(x)    (((x)>=ACAT && (x)<=VCAT) || (x)==TSPACE || (x)<=TJUXTA)


/*@::miscellaneous constants@*************************************************/
/*                                                                           */
/*  Miscellaneous globally defined constants                                 */
/*                                                                           */
/*****************************************************************************/

/* sides of a mark */
#define	BACK	           160		/* means lies to left of mark        */
#define	ON	           161		/* means lies on mark                */
#define	FWD	           162		/* means lies to right of mark       */

/* constraint statuses */
#define	PROMOTE	           163		/* this component may be promoted    */
#define	CLOSE	           164		/* must close dest before promoting  */
#define	BLOCK	           165		/* cannot promote this component     */
#define	CLEAR	           166		/* this constraint is now satisfied  */

/* gap increment types */
#define	GAP_ABS	           167		/* absolute,  e.g.  3p               */
#define	GAP_INC	           168		/* increment, e.g. +3p               */
#define	GAP_DEC	           169		/* decrement, e.g. -3p               */

/* gap modes occupying mode(x) */
#define	NO_MODE		     0		/* for error detection: no mode      */
#define	EDGE_MODE	     1		/* edge-to-edge spacing              */
#define	HYPH_MODE	     2		/* edge-to-edge with hyphenation     */
#define	MARK_MODE	     3		/* mark-to-mark spacing              */
#define	OVER_MODE	     4		/* overstrike spacing                */
#define	KERN_MODE	     5		/* kerning spacing                   */
#define	TAB_MODE	     6		/* tabulation spacing                */
#define	ADD_HYPH	     7		/* temp value used by FillObject     */

/* hyph_style(style) options                                                 */
#define	HYPH_UNDEF	     0		/* hyphenation option undefined      */
#define	HYPH_OFF	     1		/* hyphenation off                   */
#define	HYPH_ON		     2		/* hyphenation on                    */

/* fill_style(style) options                                                 */
#define	FILL_UNDEF	     0		/* fill option undefined             */
#define	FILL_OFF	     1		/* no filling of lines               */
#define	FILL_ON		     2		/* fill lines with text              */

/* underline(obj) options                                                    */
#define	UNDER_UNDEF	     0		/* underline undefined               */
#define	UNDER_OFF	     1		/* no underlining	             */
#define	UNDER_ON	     2		/* underline this                    */

/* space_style(style) options                                                */
#define	SPACE_LOUT	     0		/* interpret white space Lout's way  */
#define	SPACE_COMPRESS	     1		/* compress multiple white spaces    */
#define	SPACE_SEPARATE	     2		/* compress an separate              */
#define	SPACE_TROFF	     3		/* interpret white space troff's way */
#define	SPACE_TEX	     4		/* interpret white space TeX's way   */

/* display_style(style) options                                              */
#define	DISPLAY_UNDEF	     0		/* display option undefined          */
#define	DISPLAY_ADJUST	     1		/* adjust lines (except last)        */
#define	DISPLAY_OUTDENT	     2		/* outdent lines (except first)      */
#define	DISPLAY_ORAGGED	     3		/* outdent but don't adjust          */
#define	DISPLAY_LEFT	     4		/* left-justify lines, no adjust     */
#define	DISPLAY_CENTRE	     5		/* centre lines, no adjust           */
#define	DISPLAY_RIGHT	     6		/* right-justify lines, no adjust    */
#define	DO_ADJUST	     7		/* placed in ACATs when adjust need  */

/* small_caps(style) options                                                 */
#define	SMALL_CAPS_OFF	     0		/* don't want small capitals         */
#define	SMALL_CAPS_ON	     1		/* small capitals                    */

/* statuses of thread objects */
#define	NOTSIZED	     0		/* this thread object is not sized   */
#define	SIZED		     1		/* thread is sized but not printed   */
#define	FINALSIZE	     2		/* thread object size is now final   */

/* file types */
#define	SOURCE_FILE	     0		/* input file from command line      */
#define	INCLUDE_FILE	     1		/* @Include file                     */
#define	DATABASE_FILE	     2		/* database file                     */
#define	INDEX_FILE	     3		/* database index file               */
#define	FONT_FILE	     4		/* font file                         */
#define	PREPEND_FILE	     5		/* PostScript prologue file          */
#define	HYPH_FILE	     6		/* hyphenation file                  */
#define	HYPH_PACKED_FILE     7		/* packed hyphenation file           */
#define	MAPPING_FILE	     8		/* character mapping file            */
#define	FILTER_FILE	     9		/* filter output file                */
#define	MAX_TYPES	    10		/* number of file types              */

/* path types (i.e. sequences of directories for file searching) */
#define	SOURCE_PATH	     0		/* path to search for source files   */
#define	INCLUDE_PATH	     1		/* path for @Include files           */
#define	SYSINCLUDE_PATH	     2		/* path for @SysInclude files        */
#define	DATABASE_PATH	     3		/* path for @Database files          */
#define	SYSDATABASE_PATH     4		/* path for @SysDatabase files       */
#define	FONT_PATH	     5		/* path for font metrics (AFM) files */
#define	HYPH_PATH	     6		/* path for hyphenation files        */
#define	MAPPING_PATH	     7		/* path for mapping (LCM) files      */
#define	MAX_PATHS	     8		/* number of mapping paths           */

/* units of measurement */
#define	NO_UNIT		     0		/* no unit - for error detection     */
#define	FIXED_UNIT	     1		/* inches, cm, points, ems, y, z     */
#define	FRAME_UNIT	     2		/* b unit (frame widths)             */
#define	AVAIL_UNIT	     3		/* r unit (available spaces)         */
#define	DEG_UNIT	     4		/* d unit (degrees)                  */
#define	NEXT_UNIT	     5		/* w unit (inners)                   */
 
/* units of distance as multiples of the basic unit */
#define	CM	           567		/* 1 centimetre                      */
#define	IN	          1440		/* 1 inch                            */
#define	EM	           120		/* 1 em (= 1/12 inch)                */
#define	PT		    20		/* 1 point (= 1/72 inch)             */
#define	FR	          4096		/* virtual unit for frame units      */
#define	DG	           128		/* virtual unit for degrees          */
#define	SF	           256		/* virtual unit for @Scale factors   */
                                        /* including blankline scale         */

/* default size of characters for the PLAINTEXT back end */
#define	PLAIN_WIDTH        144		/* default char width, 10 per inch   */
#define	PLAIN_HEIGHT       240		/* default char height, 6 per inch   */

/* precedences */
#define	NO_PREC		     0		/* lower than any precedence         */
#define	BEGIN_PREC	     1		/* precedence of @Begin              */
#define	END_PREC	     2		/* precedence of @End                */
#define	LBR_PREC	     3		/* precedence of {                   */
#define	RBR_PREC	     4		/* precedence of }                   */
#define	VCAT_PREC	     5		/* precedence of /                   */
#define	HCAT_PREC	     6		/* precedence of |                   */
#define	ACAT_PREC	     7		/* precedence of & and white space   */
#define	MIN_PREC            10		/* minimum precedence of user ops    */
#define	MAX_PREC           100		/* maximim precedence of user ops    */
#define	DEFAULT_PREC       100		/* default precedence of user ops    */
#define CROSSOP_PREC       101		/* precedence of && and &&& ops      */
#define GAP_PREC           102		/* precedence of gap op after cat op */
#define JUXTA_PREC         103		/* precedence of juxtaposition &     */
#define	FILTER_PREC        104		/* precedence of filter symbol ops   */
#define	FORCE_PREC         105		/* higher than any precedence        */

/* back ends */
#define POSTSCRIPT           0		/* PostScript back end               */
#define	PDF		     1		/* PDF back end			     */
#define	PLAINTEXT	     2		/* plain text back end               */

/* error types */
#define	INTERN		     0		/* internal error (i.e. bug)         */
#define	FATAL		     1		/* fatal error, abort now            */
#define	FATAL_WITH_USAGE     2		/* fatal error, abort now + usage    */
#define	WARN		     3		/* warning, non-fatal                */

/* status values returned by AttachGalley() */
#define	ATTACH_KILLED	     0
#define	ATTACH_INPUT	     1
#define	ATTACH_NOTARGET	     2
#define	ATTACH_SUSPEND	     3
#define	ATTACH_NULL	     4
#define	ATTACH_ACCEPT	     5

/* kinds of tidying up accepted by ReplaceWithTidy */
#define	ACAT_TIDY	     0
#define	WORD_TIDY	     1
#define	PARA_TIDY	     2

/* types of memory usage, used to debug memory consumption */
#define	MEM_BINARY	     0		/* the executable binary	     */
#define	MEM_OBJECTS	     1		/* objects currently in free list    */
#define	MEM_FONTS	     2		/* fonts                             */
#define	MEM_LEX		     3		/* lexical analyser file buffers     */
#define	MEM_FILES	     4		/* table of file names               */
#define	MEM_CROSSREF	     5		/* table of file names               */
#define	MEM_PAGES	     6		/* page grids (-p only)              */
#define	MEM_DBCHECK	     7		/* database checks                   */
#define	MEM_DB	             8		/* in_memory database                */
#define	MEM_HYPH_PATS	     9		/* hyphenation patterns              */
#define	MEM_CMAPS	    10		/* character maps                    */
#define	MEM_COLOUR_TAB	    11		/* colour table                      */
#define	MEM_TEXTURE_TAB	    12		/* texture table                     */
#define	MEM_LANG_TAB	    13		/* language table                    */
#define	MEM_USAGE_MAX	    14		/* number of memory usage types      */

/*@::Keywords@****************************************************************/
/*                                                                           */
/*  Keywords.                                                                */
/*                                                                           */
/*****************************************************************************/

#define	KW_START		AsciiToFull("\\Start")
#define	KW_PRINT		AsciiToFull("\\Print")
#define	KW_OPTGALL		AsciiToFull("@OptGall")
#define	KW_DEF			AsciiToFull("def")
#define	KW_FONTDEF		AsciiToFull("@FontDef")
#define	KW_FAMILY		AsciiToFull("@Family")
#define	KW_FACE			AsciiToFull("@Face")
#define	KW_NAME			AsciiToFull("@Name")
#define	KW_METRICS		AsciiToFull("@Metrics")
#define	KW_EXTRA_METRICS	AsciiToFull("@ExtraMetrics")
#define	KW_MAPPING		AsciiToFull("@Mapping")
#define	KW_RECODE		AsciiToFull("@Recode")
#define	KW_LANGDEF		AsciiToFull("langdef")
#define	KW_FORCE		AsciiToFull("force")
#define	KW_HORIZ		AsciiToFull("horizontally")
#define	KW_INTO			AsciiToFull("into")
#define	KW_EXTEND		AsciiToFull("extend")
#define	KW_IMPORT		AsciiToFull("import")
#define	KW_EXPORT		AsciiToFull("export")
#define	KW_PRECEDENCE		AsciiToFull("precedence")
#define	KW_ASSOC		AsciiToFull("associativity")
#define	KW_LEFT			AsciiToFull("left")
#define	KW_RIGHT		AsciiToFull("right")
#define	KW_BODY			AsciiToFull("body")
#define	KW_FILTER		AsciiToFull("@Filter")
#define	KW_FILTERIN		AsciiToFull("@FilterIn")
#define	KW_FILTEROUT		AsciiToFull("@FilterOut")
#define	KW_FILTERERR		AsciiToFull("@FilterErr")
#define	KW_MACRO		AsciiToFull("macro")
#define	KW_NAMED		AsciiToFull("named")
#define	KW_COMPULSORY		AsciiToFull("compulsory")
#define	KW_COMMON		AsciiToFull("@Common")
#define	KW_RUMP			AsciiToFull("@Rump")
#define	KW_MELD			AsciiToFull("@Meld")
#define	KW_INSERT		AsciiToFull("@Insert")
#define	KW_ONE_OF		AsciiToFull("@OneOf")
#define	KW_NEXT			AsciiToFull("@Next")
#define	KW_PLUS			AsciiToFull("@Plus")
#define	KW_MINUS		AsciiToFull("@Minus")
#define	KW_WIDE			AsciiToFull("@Wide")
#define	KW_HIGH			AsciiToFull("@High")
#define	KW_HSHIFT		AsciiToFull("@HShift")
#define	KW_VSHIFT		AsciiToFull("@VShift")
#define	KW_BEGIN_HEADER		AsciiToFull("@BeginHeaderComponent")
#define	KW_END_HEADER		AsciiToFull("@EndHeaderComponent")
#define	KW_SET_HEADER		AsciiToFull("@SetHeaderComponent")
#define	KW_CLEAR_HEADER		AsciiToFull("@ClearHeaderComponent")
#define	KW_ONE_COL		AsciiToFull("@OneCol")
#define	KW_ONE_ROW		AsciiToFull("@OneRow")
#define	KW_HMIRROR		AsciiToFull("@HMirror")
#define	KW_VMIRROR		AsciiToFull("@VMirror")
#define	KW_HSCALE		AsciiToFull("@HScale")
#define	KW_VSCALE		AsciiToFull("@VScale")
#define	KW_HCOVER		AsciiToFull("@HCover")
#define	KW_VCOVER		AsciiToFull("@VCover")
#define	KW_SCALE		AsciiToFull("@Scale")
#define	KW_KERN_SHRINK		AsciiToFull("@KernShrink")
#define	KW_HCONTRACT		AsciiToFull("@HContract")
#define	KW_VCONTRACT		AsciiToFull("@VContract")
#define	KW_HLIMITED		AsciiToFull("@HLimited")
#define	KW_VLIMITED		AsciiToFull("@VLimited")
#define	KW_HEXPAND		AsciiToFull("@HExpand")
#define	KW_VEXPAND		AsciiToFull("@VExpand")
#define	KW_STARTHVSPAN		AsciiToFull("@StartHVSpan")
#define	KW_STARTHSPAN		AsciiToFull("@StartHSpan")
#define	KW_STARTVSPAN		AsciiToFull("@StartVSpan")
#define	KW_HSPAN		AsciiToFull("@HSpan")
#define	KW_VSPAN		AsciiToFull("@VSpan")
#define	KW_PADJUST		AsciiToFull("@PAdjust")
#define	KW_HADJUST		AsciiToFull("@HAdjust")
#define	KW_VADJUST		AsciiToFull("@VAdjust")
#define	KW_ROTATE		AsciiToFull("@Rotate")
#define	KW_BACKGROUND		AsciiToFull("@Background")
#define	KW_INCGRAPHIC		AsciiToFull("@IncludeGraphic")
#define	KW_SINCGRAPHIC		AsciiToFull("@SysIncludeGraphic")
#define	KW_GRAPHIC		AsciiToFull("@Graphic")
#define	KW_LINK_SOURCE		AsciiToFull("@LinkSource")
#define	KW_LINK_DEST		AsciiToFull("@LinkDest")
#define	KW_LINK_URL		AsciiToFull("@URLLink")
#define	KW_PLAINGRAPHIC		AsciiToFull("@PlainGraphic")
#define	KW_VERBATIM		AsciiToFull("@Verbatim")
#define	KW_RAWVERBATIM		AsciiToFull("@RawVerbatim")
#define	KW_CASE			AsciiToFull("@Case")
#define	KW_YIELD		AsciiToFull("@Yield")
#define	KW_BACKEND		AsciiToFull("@BackEnd")
#define	KW_XCHAR		AsciiToFull("@Char")
#define	KW_FONT			AsciiToFull("@Font")
#define	KW_SPACE		AsciiToFull("@Space")
#define	KW_YUNIT		AsciiToFull("@YUnit")
#define	KW_ZUNIT		AsciiToFull("@ZUnit")
#define	KW_BREAK		AsciiToFull("@Break")
#define	KW_UNDERLINE		AsciiToFull("@Underline")
#define	KW_COLOUR		AsciiToFull("@SetColour")
#define	KW_COLOR		AsciiToFull("@SetColor")
#define	KW_UNDERLINE_COLOUR	AsciiToFull("@SetUnderlineColour")
#define	KW_UNDERLINE_COLOR	AsciiToFull("@SetUnderlineColor")
#define	KW_TEXTURE		AsciiToFull("@SetTexture")
#define	KW_OUTLINE		AsciiToFull("@Outline")
#define	KW_LANGUAGE		AsciiToFull("@Language")
#define	KW_CURR_LANG		AsciiToFull("@CurrLang")
#define	KW_CURR_FAMILY		AsciiToFull("@CurrFamily")
#define	KW_CURR_FACE		AsciiToFull("@CurrFace")
#define	KW_CURR_YUNIT		AsciiToFull("@CurrYUnit")
#define	KW_CURR_ZUNIT		AsciiToFull("@CurrZUnit")
#define	KW_ENV			AsciiToFull("@LEnv")
#define	KW_ENVA			AsciiToFull("@@A")
#define	KW_ENVB			AsciiToFull("@@B")
#define	KW_ENVC			AsciiToFull("@@C")
#define	KW_ENVD			AsciiToFull("@@D")
#define	KW_CENV			AsciiToFull("@@E")
#define	KW_CLOS			AsciiToFull("@LClos")
#define	KW_LVIS			AsciiToFull("@@V")
#define	KW_LUSE			AsciiToFull("@LUse")
#define	KW_LEO			AsciiToFull("@LEO")
#define	KW_OPEN			AsciiToFull("@Open")
#define	KW_USE			AsciiToFull("@Use")
#define	KW_NOT_REVEALED		AsciiToFull("@NotRevealed")
#define	KW_TAGGED		AsciiToFull("@Tagged")
#define	KW_DATABASE		AsciiToFull("@Database")
#define	KW_SYSDATABASE		AsciiToFull("@SysDatabase")
#define	KW_INCLUDE		AsciiToFull("@Include")
#define	KW_SYSINCLUDE		AsciiToFull("@SysInclude")
#define	KW_INCG_REPEATED	AsciiToFull("@IncludeGraphicRepeated")
#define	KW_SINCG_REPEATED	AsciiToFull("@SysIncludeGraphicRepeated")
#define	KW_PREPEND		AsciiToFull("@PrependGraphic")
#define	KW_SYSPREPEND		AsciiToFull("@SysPrependGraphic")
#define	KW_TARGET		AsciiToFull("@Target")
#define	KW_FOLLOWING		AsciiToFull("following")
#define	KW_PRECEDING		AsciiToFull("preceding")
#define	KW_FOLL_OR_PREC		AsciiToFull("foll_or_prec")
#define	KW_NOW			AsciiToFull("now")
#define	KW_NULL			AsciiToFull("@Null")
#define	KW_PAGE_LABEL		AsciiToFull("@PageLabel")
#define	KW_GALLEY		AsciiToFull("@Galley")
#define	KW_FORCE_GALLEY		AsciiToFull("@ForceGalley")
#define	KW_INPUT		AsciiToFull("@LInput")
#define	KW_SPLIT		AsciiToFull("@Split")
#define	KW_TAG			AsciiToFull("@Tag")
#define	KW_KEY			AsciiToFull("@Key")
#define	KW_OPTIMIZE		AsciiToFull("@Optimize")
#define	KW_MERGE		AsciiToFull("@Merge")
#define	KW_ENCLOSE		AsciiToFull("@Enclose")
#define	KW_CROSS		AsciiToFull("&&")
#define	KW_FORCE_CROSS		AsciiToFull("&&&")
#define	KW_LBR			AsciiToFull("{")
#define	KW_RBR			AsciiToFull("}")
#define	KW_BEGIN		AsciiToFull("@Begin")
#define	KW_END			AsciiToFull("@End")
#define	KW_VCAT_NN		AsciiToFull("//")
#define	KW_VCAT_MN		AsciiToFull("^//")
#define	KW_VCAT_NJ		AsciiToFull("/")
#define	KW_VCAT_MJ		AsciiToFull("^/")
#define	KW_HCAT_NN		AsciiToFull("||")
#define	KW_HCAT_MN		AsciiToFull("^||")
#define	KW_HCAT_NJ		AsciiToFull("|")
#define	KW_HCAT_MJ		AsciiToFull("^|")
#define	KW_ACAT_NJ		AsciiToFull("&")
#define	KW_ACAT_MJ		AsciiToFull("^&")
#define	KW_MOMENT		AsciiToFull("@Moment")
#define	KW_SECOND		AsciiToFull("@Second")
#define	KW_MINUTE		AsciiToFull("@Minute")
#define	KW_HOUR			AsciiToFull("@Hour")
#define	KW_DAY			AsciiToFull("@Day")
#define	KW_MONTH		AsciiToFull("@Month")
#define	KW_YEAR			AsciiToFull("@Year")
#define	KW_CENTURY		AsciiToFull("@Century")
#define	KW_WEEKDAY		AsciiToFull("@WeekDay")
#define	KW_YEARDAY		AsciiToFull("@YearDay")
#define	KW_DAYLIGHTSAVING	AsciiToFull("@DaylightSaving")
#define	KW_SET_CONTEXT		AsciiToFull("@SetContext")
#define	KW_GET_CONTEXT		AsciiToFull("@GetContext")

/*@::GetMem(), New(), NewWord()@**********************************************/
/*                                                                           */
/*  GetMem(x, siz, pos)                                                      */
/*  New(x, typ)                                                              */
/*  NewWord(x, typ, len, pos)                                                */
/*                                                                           */
/*  Set x to point to a new record, of appropriate length (in ALIGNs).       */
/*  The New and NewWord versions initialise LIST, type and rec_size fields.  */
/*  NewWord must be used for WORD and QWORD objects.                         */
/*                                                                           */
/*****************************************************************************/

#if DEBUG_ON
#define newcount zz_newcount++
#define freecount zz_listcount--

#define checknew(typ)							\
{ assert1( is_type(typ), "New: type", Image(typ) );			\
  assert(  zz_lengths[typ] > 0, "New: zero length!" );			\
}

#define checkmem(z, typ)						\
{ if( (MemCheck != 0) && ( (POINTER) z == MemCheck) )			\
    fprintf(stderr, "%ld = New(%s)%s",(long)z,Image(type(z)),STR_NEWLINE); \
}

#else
#define newcount
#define freecount
#define checknew(typ)
#define checkmem(z, typ)
#endif

#define	GetMem(x, siz, pos)						\
{ newcount;								\
  if( (zz_size=(siz)) >= MAX_OBJECT_REC )				\
    x = NULL, Error(1, 1, "word is too long", FATAL, pos);		\
  else if( zz_free[zz_size] == nilobj )					\
    x = GetMemory(zz_size, pos);					\
  else									\
  { x = zz_free[zz_size];						\
    freecount;								\
    zz_free[zz_size] = pred(x, CHILD);					\
  }									\
}

#define	New(x, typ)							\
{ checknew(typ);							\
  GetMem(zz_hold, zz_lengths[typ], no_fpos);				\
  type(zz_hold) = typ;							\
  checkmem(zz_hold, typ);						\
  x = pred(zz_hold, CHILD) = succ(zz_hold, CHILD) =			\
  pred(zz_hold, PARENT) = succ(zz_hold, PARENT) = zz_hold;		\
}

#define NewWord(x, typ, len, pos)					\
{ zz_size = sizeof(struct word_type) - 4 + ((len)+1)*sizeof(FULL_CHAR);	\
  /* NB the following line RESETS zz_size */				\
  GetMem(zz_hold, ceiling(zz_size, sizeof(ALIGN)), pos);		\
  checkmem(zz_hold, typ);						\
  rec_size(zz_hold) = zz_size;						\
  type(zz_hold) = typ;							\
  x = pred(zz_hold, CHILD) = succ(zz_hold, CHILD) =			\
  pred(zz_hold, PARENT) = succ(zz_hold, PARENT) = zz_hold;		\
}

/*@::PutMem(), Dispose()@*****************************************************/
/*                                                                           */
/*  PutMem(x, siz)                                                           */
/*  Dispose(x)                                                               */
/*                                                                           */
/*  Dispose x, which is of size siz.  Dispose works out the size itself.     */
/*                                                                           */
/*****************************************************************************/
#if DEBUG_ON
#define disposecount zz_disposecount++; zz_listcount++;

#define disposecheck							\
{ assert( zz_size >= 0 && zz_size < MAX_OBJECT_REC, "Dispose: size" );	\
}
 
#define	setdisposed							\
{ if( (MemCheck != 0) && ((POINTER) zz_hold == MemCheck) )		\
    fprintf(stderr, "Dispose(%ld, %s)%s", (long) zz_hold,		\
      Image(type(zz_hold)), STR_NEWLINE);				\
  type(zz_hold) = DISPOSED;						\
}

#else
#define disposecount
#define disposecheck
#define	setdisposed
#endif

#define PutMem(x, siz)							\
{ disposecount;								\
  zz_hold = (x);							\
  zz_size = (siz);							\
  disposecheck;								\
  pred(zz_hold, CHILD) = zz_free[zz_size];				\
  zz_free[zz_size] = zz_hold;						\
}

#define Dispose(x)							\
{ zz_hold = (x);							\
  PutMem(zz_hold, is_word(type(zz_hold)) ?				\
    rec_size(zz_hold) : zz_lengths[type(zz_hold)]);			\
  setdisposed;								\
}

/*@::Append(), Delete()@******************************************************/
/*                                                                           */
/*  OBJECT Append(x, y, dir)                                                 */
/*                                                                           */
/*  Return the append of lists x and y (dir is PARENT or CHILD).             */
/*                                                                           */
/*****************************************************************************/

#define	Append(x, y, dir)						\
( zz_res = (x),	zz_hold = (y),						\
  zz_hold == nilobj ? zz_res  :						\
  zz_res  == nilobj ? zz_hold :						\
  ( zz_tmp = pred(zz_hold, dir),					\
    pred(zz_hold, dir) = pred(zz_res, dir),				\
    succ(pred(zz_res, dir), dir) = zz_hold,				\
    pred(zz_res, dir) = zz_tmp,						\
    succ(zz_tmp, dir) = zz_res						\
  )									\
)


/*****************************************************************************/
/*                                                                           */
/*  OBJECT Delete(x, dir)                                                    */
/*                                                                           */
/*  Delete x from its dir list, and return succ(x, dir) or nilobj if none.   */
/*                                                                           */
/*****************************************************************************/

#define Delete(x, dir)							\
( zz_hold = (x),							\
  succ(zz_hold, dir) == zz_hold ? nilobj :				\
  ( zz_res = succ(zz_hold, dir),					\
    pred(zz_res, dir) = pred(zz_hold, dir),				\
    succ(pred(zz_hold, dir), dir) = zz_res,				\
    pred(zz_hold, dir) = succ(zz_hold, dir) = zz_hold,			\
    zz_res								\
  )									\
)

#define Down(x)		succ(x, CHILD)
#define NextDown(x)	succ(x, CHILD)
#define LastDown(x)	pred(x, CHILD)
#define PrevDown(x)	pred(x, CHILD)
#define	Up(x)		succ(x, PARENT)
#define	NextUp(x)	succ(x, PARENT)
#define	LastUp(x)	pred(x, PARENT)
#define	PrevUp(x)	pred(x, PARENT)

#define	Child(y, link)							\
for( y = pred(link, PARENT);  type(y) == LINK;  y = pred(y, PARENT) )

#define CountChild(y, link, i)                                          \
for( y=pred(link, PARENT), i=1; type(y)==LINK;  y = pred(y, PARENT), i++ )

#define	Parent(y, link)							\
for( y = pred(link, CHILD);   type(y) == LINK;  y = pred(y, CHILD) )


/*@::UpDim(), DownDim(), Link(), DeleteLink(), etc.@**************************/
/*                                                                           */
/*  UpDim(x, dim)                                                            */
/*  DownDim(x, dim)                                                          */
/*                                                                           */
/*  Returns the dim child or parent link of node x (dim == COLM or ROWM).    */
/*                                                                           */
/*****************************************************************************/

#define UpDim(x, dim)	( (dim) == COLM ? succ(x, PARENT) : pred(x, PARENT) )
#define DownDim(x, dim)	( (dim) == COLM ? succ(x, CHILD) : pred(x, CHILD) )


/*****************************************************************************/
/*                                                                           */
/*  OBJECT Link(x, y)                                                        */
/*                                                                           */
/*  Make y a child of x in the directed graph, using a new link.             */
/*  The link node is returned.                                               */
/*                                                                           */
/*****************************************************************************/

#define Link(x, y)							\
{ New(xx_link, LINK);							\
  Append(xx_link, (x), CHILD);						\
  Append(xx_link, (y), PARENT);						\
}


/*****************************************************************************/
/*                                                                           */
/*  DeleteLink(link)                                                         */
/*                                                                           */
/*  Cut the link between nodes x and y of the directed graph.                */
/*  Returns the link node of the next child of x, or x if none.              */
/*                                                                           */
/*****************************************************************************/

#define DeleteLink(link)						\
{ xx_link = (link);							\
  Delete(xx_link, PARENT);						\
  Delete(xx_link, CHILD);						\
  Dispose(xx_link);							\
}


/*****************************************************************************/
/*                                                                           */
/*  DisposeChild(link)                                                       */
/*                                                                           */
/*  Delete link, and if its child is thereby unattached, dispose it.         */
/*                                                                           */
/*****************************************************************************/

#define DisposeChild(link)						\
{ xx_link = (link);							\
  xx_tmp = Delete(xx_link, PARENT);					\
  Delete(xx_link, CHILD);						\
  Dispose(xx_link);							\
  if( succ(xx_tmp, PARENT) == xx_tmp )  DisposeObject(xx_tmp);		\
} /* end DisposeChild */


/*****************************************************************************/
/*                                                                           */
/*  MoveLink(link, x, dir)                                                   */
/*                                                                           */
/*  Move the dir end of link from wherever it is now to node x.              */
/*                                                                           */
/*****************************************************************************/

#define MoveLink(link, x, dir)						\
( xx_link = (link),							\
  Delete(xx_link, 1 - (dir) ),						\
  Append(xx_link, (x), 1 - (dir) )					\
) /* end MoveLink */


/*@::TransferLinks(), DeleteNode(), etc.@*************************************/
/*                                                                           */
/*  TransferLinks(start_link, stop_link, dest_link)                          */
/*                                                                           */
/*  Move parent end of links start_link (inclusive) to stop_link (exclusive) */
/*  to just before dest_link.                                                */
/*                                                                           */
/*****************************************************************************/

#define TransferLinks(start_link, stop_link, dest_link)			\
{ OBJECT xxstart = start_link, xxstop = stop_link, xxdest = dest_link;	\
  if( xxstart != xxstop )						\
  {	assert( type(xxstart) == LINK, "TransferLinks: start_link!" );	\
	Append(xxstart, xxstop, CHILD); /* actually a split */		\
	Append(xxstart, xxdest, CHILD);					\
  }									\
}


/*****************************************************************************/
/*                                                                           */
/*  DeleteNode(x)                                                            */
/*                                                                           */
/*  Delete node x and every edge attaching to x.                             */
/*                                                                           */
/*****************************************************************************/

#define DeleteNode(x)							\
{ xx_hold = (x);							\
  while( Up(xx_hold)   != xx_hold ) DeleteLink( Up(xx_hold) );		\
  while( Down(xx_hold) != xx_hold ) DeleteLink( Down(xx_hold) );	\
  Dispose(xx_hold);							\
}


/*****************************************************************************/
/*                                                                           */
/*  MergeNode(x, y)                                                          */
/*                                                                           */
/*  Take all the children of y and make them children of x.                  */
/*  Take all the parents of y and make them parents of x.  Dispose y.        */
/*                                                                           */
/*****************************************************************************/

#define MergeNode(x, y)							\
{ xx_res = (x); xx_hold = (y);						\
  xx_tmp = Delete(xx_hold, PARENT);					\
  Append(xx_res, xx_tmp, PARENT);					\
  xx_tmp = Delete(xx_hold, CHILD);					\
  Append(xx_res, xx_tmp, CHILD);					\
  Dispose(xx_hold);							\
}  /* end MergeNode */


/*****************************************************************************/
/*                                                                           */
/*  ReplaceNode(x, y)                                                        */
/*                                                                           */
/*  Move all the parent links of y to x.                                     */
/*                                                                           */
/*****************************************************************************/

#define ReplaceNode(x, y)						\
( xx_tmp = Delete((y), PARENT),						\
  Append((x), xx_tmp, PARENT)						\
) /* end ReplaceNode */


/*@::FirstDefinite(), NextDefinite(), etc.@***********************************/
/*                                                                           */
/*  FirstDefinite(x, link, y, jn)                                            */
/*                                                                           */
/*  On input, x is an object and link and y are undefined.  On output there  */
/*  are two cases:                                                           */
/*                                                                           */
/*  link != x.  Then y is first definite child of x and link is its link;    */
/*              jn is TRUE iff all gaps on the way to link were joined.      */
/*                                                                           */
/*  link == x.  Then x has no definite child and y is undefined.             */
/*                                                                           */
/*  A SPLIT object is considered to be definite if both its children are     */
/*  definite.  This condition is returned by SplitIsDefinite.                */
/*                                                                           */
/*****************************************************************************/

#define FirstDefinite(x, link, y, jn)					\
{ jn = TRUE;								\
  for( link = Down(x);  link != x;  link = NextDown(link) )		\
  { Child(y, link);							\
    if( type(y) == GAP_OBJ )  jn = jn && join(gap(y));			\
    else if( type(y)==SPLIT ? SplitIsDefinite(y) : is_definite(type(y)))\
      break;								\
  }									\
} /* end FirstDefinite */


/*****************************************************************************/
/*                                                                           */
/*  NextDefinite(x, link, y)                                                 */
/*                                                                           */
/*  On input, x is an object and link is a link to one of its children; y    */
/*  is undefined.  On output there are two cases:                            */
/*                                                                           */
/*  link != x.  Then y is the first definite child of x following link, and  */
/*              link is changed to be the link of y.                         */
/*                                                                           */
/*  link == x.  Then x has no definite child following link, and y remains   */
/*              undefined.                                                   */
/*                                                                           */
/*****************************************************************************/

#define NextDefinite(x, link, y)					\
{ for( link = NextDown(link);  link != x;  link = NextDown(link) )	\
  { Child(y, link);							\
    if( type(y) == SPLIT ? SplitIsDefinite(y) : is_definite(type(y)) )	\
	break;								\
  }									\
} /* end NextDefinite */


/*****************************************************************************/
/*                                                                           */
/*  NextDefiniteWithGap(x, link, y, g, jn)                                   */
/*                                                                           */
/*  On input, x is an object and link is a link to one of its children; y    */
/*  and g are undefined.  On output there are two cases:                     */
/*                                                                           */
/*  link != x.  Then y is the first definite child of x following link, and  */
/*              link is changed to be the link of y.  Also, g is defined     */
/*              to be the gap just before y; this must exist and is tested   */
/*              by an assert test; and jn is true iff all of the gaps on     */
/*              the way from old link to new link are join gaps.             */
/*                                                                           */
/*  link == x.  Then x has no definite child following link, and y and g     */
/*              remain undefined.                                            */
/*                                                                           */
/*****************************************************************************/

#define NextDefiniteWithGap(x, link, y, g, jn)				\
{ g = nilobj;  jn = TRUE;						\
  for( link = NextDown(link);  link != x;  link = NextDown(link) )	\
  { Child(y, link);							\
    if( type(y) == GAP_OBJ )  g = y, jn = jn && join(gap(y));		\
    else if( type(y)==SPLIT ? SplitIsDefinite(y):is_definite(type(y)) )	\
    {									\
      debug2(DFS, DD, "  NextDefiniteWithGap at %s %s",			\
	Image(type(y)), EchoObject(y));					\
      assert( g != nilobj, "NextDefiniteWithGap: g == nilobj!" );	\
      break;								\
    }									\
  }									\
} /* end NextDefiniteWithGap */

/*@@**************************************************************************/
/*                                                                           */
/*  LastDefinite(x, link, y)                                                 */
/*                                                                           */
/*  On input, x is an object and link and y are undefined.  On output there  */
/*  are two cases:                                                           */
/*                                                                           */
/*  link != x.  Then y is the last definite child of x and link is its link. */
/*                                                                           */
/*  link == x.  Then x has no definite child and y is undefined.             */
/*                                                                           */
/*  A SPLIT object is considered to be definite if both its children are     */
/*  definite.  This condition is returned by SplitIsDefinite.                */
/*                                                                           */
/*****************************************************************************/

#define LastDefinite(x, link, y)					\
{ for( link = LastDown(x);  link != x;  link = PrevDown(link) )		\
  { Child(y, link);							\
    if( type(y) == SPLIT ? SplitIsDefinite(y) : is_definite(type(y)) )	\
	break;								\
  }									\
} /* end LastDefinite */


/*****************************************************************************/
/*                                                                           */
/*  PrevDefinite(x, link, y)                                                 */
/*                                                                           */
/*  On input, x is an object and link is a link to one of its children; y    */
/*  is undefined.  On output there are two cases:                            */
/*                                                                           */
/*  link != x.  Then y is the first definite child of x preceding link, and  */
/*              link is changed to be the link of y.                         */
/*                                                                           */
/*  link == x.  Then x has no definite child preceding link, and y remains   */
/*              undefined.                                                   */
/*                                                                           */
/*****************************************************************************/

#define PrevDefinite(x, link, y)					\
{ for( link = PrevDown(link);  link != x;  link = PrevDown(link) )	\
  { Child(y, link);							\
    if( type(y) == SPLIT ? SplitIsDefinite(y) : is_definite(type(y)) )	\
	break;								\
  }									\
} /* end PrevDefinite */


/*@::Module Declarations@*****************************************************/
/*                                                                           */
/*  MODULE DECLARATIONS                                                      */
/*                                                                           */
/*****************************************************************************/

/*****  z01.c	  Supervise		**************************************/
extern	void	  PrintUsage(FILE *fp);
extern	int	  main(int argc, char *argv[]);
extern	POINTER	  MemCheck;
extern	OBJECT	  StartSym;
extern	OBJECT	  GalleySym;
extern	OBJECT	  ForceGalleySym;
extern	OBJECT	  InputSym;
extern	OBJECT	  PrintSym;
extern	OBJECT	  FilterInSym;
extern	OBJECT	  FilterOutSym;
extern	OBJECT	  FilterErrSym;
extern	OBJECT	  VerbatimSym;
extern	OBJECT	  RawVerbatimSym;
extern	OBJECT	  OptGallSym;
extern	BACK_END  BackEnd;
extern	OBJECT	  CommandOptions;
extern	BOOLEAN	  AllowCrossDb;
extern	BOOLEAN	  UseCollate;
extern	BOOLEAN	  InMemoryDbIndexes;
extern	BOOLEAN	  Kern;
extern	BOOLEAN	  SafeExecution;
extern	BOOLEAN   AltErrorFormat;
extern	int	  TotalWordCount;
extern	BOOLEAN	  InitializeAll;
#if LOCALE_ON
extern	nl_catd	  MsgCat;
#endif

/*****  z02.c	  Lexical Analyser	**************************************/
extern	BOOLEAN	  LexLegalName(FULL_CHAR *str);
extern	void	  LexInit(void);
extern	void	  LexPush(FILE_NUM x, int offs, int ftyp, int lnum, BOOLEAN same);
extern	void	  LexPop(void);
extern	long	  LexNextTokenPos(void);
extern	OBJECT	  LexGetToken(void);
extern	OBJECT	  LexScanVerbatim(FILE *fp, BOOLEAN end_stop, FILE_POS *err_pos,
		    BOOLEAN lessskip);

/*****  z03.c	  File Service	        **************************************/
extern	FILE_POS  *no_fpos;
extern	void	  InitFiles(void);
extern	void	  AddToPath(int fpath, OBJECT dirname);
extern	FILE_NUM  DefineFile(FULL_CHAR *str, FULL_CHAR *suffix,
		    FILE_POS *xfpos, int ftype, int fpath);
extern	FILE_NUM  FirstFile(int ftype);
extern	FILE_NUM  NextFile(FILE_NUM i);
extern	FILE_NUM  FileNum(FULL_CHAR *str, FULL_CHAR *suffix);
extern	FILE_NUM  DatabaseFileNum(FILE_POS *xfpos);
extern	FULL_CHAR *FileName(FILE_NUM fnum);
extern	FULL_CHAR *FullFileName(FILE_NUM fnum);
extern	int	  FileType(FILE_NUM fnum);
extern	FULL_CHAR *EchoFilePos(FILE_POS *pos);
extern	FULL_CHAR *EchoAltFilePos(FILE_POS *pos);
extern	FULL_CHAR *EchoFileSource(FILE_NUM fnum);
extern	FULL_CHAR *EchoFileLine(FILE_POS *pos);
extern	FILE_POS  *PosOfFile(FILE_NUM fnum);
extern	FILE	  *OpenFile(FILE_NUM fnum, BOOLEAN check_ld, BOOLEAN check_lt);
extern	FILE	  *OpenIncGraphicFile(FULL_CHAR *str, unsigned char typ,
		    OBJECT *full_name, FILE_POS *xfpos, BOOLEAN *compressed);
extern	void	  FileSetUpdated(FILE_NUM fnum, int newlines);
extern	int	  FileGetLineCount(FILE_NUM fnum);
extern	BOOLEAN	  FileTestUpdated(FILE_NUM fnum);

/*****  z04.c	  Token Service	        **************************************/
extern	OBJECT	  NewToken(unsigned char xtype, FILE_POS *xfpos,
		    unsigned char xvspace, unsigned char xhspace,
		    unsigned char xprec, OBJECT xactual);
extern	OBJECT	  CopyTokenList(OBJECT x, FILE_POS *pos);
extern	FULL_CHAR *EchoCatOp(unsigned xtype, BOOLEAN xmark, BOOLEAN xjoin);
extern	FULL_CHAR *EchoToken(OBJECT x);

/*****  z05.c	  Read Definitions  	**************************************/
extern	void	  ReadPrependDef(unsigned typ, OBJECT encl);
extern	void	  ReadIncGRepeatedDef(unsigned typ, OBJECT encl);
extern	void	  ReadDatabaseDef(unsigned typ, OBJECT encl);
extern	void	  ReadDefinitions(OBJECT *token, OBJECT encl,
		    unsigned char res_type);

/*****  z06.c	  Object Parser	        **************************************/
extern	BOOLEAN	  InDefinitions;
extern	void	  SetScope(OBJECT env, int *count, BOOLEAN vis_only);
extern	void	  InitParser(FULL_CHAR *cross_db);
extern	OBJECT	  Parse(OBJECT *token, OBJECT encl, BOOLEAN defs_allowed,
		    BOOLEAN transfer_allowed);

/*****  z07.c	  Object Service	**************************************/
extern	BOOLEAN	  SplitIsDefinite(OBJECT x);
extern	int	  DisposeObject(OBJECT x);
extern	OBJECT	  MakeWord(unsigned typ, FULL_CHAR *str, FILE_POS *pos);
extern	OBJECT	  MakeWordTwo(unsigned typ, FULL_CHAR *str1, FULL_CHAR *str2,
		    FILE_POS *pos);
extern	OBJECT	  MakeWordThree(FULL_CHAR *s1, FULL_CHAR *s2, FULL_CHAR *s3);
extern	OBJECT	  CopyObject(OBJECT x, FILE_POS *pos);
extern	OBJECT	  InsertObject(OBJECT x, OBJECT *ins, STYLE *style);
extern	OBJECT	  Meld(OBJECT x, OBJECT y);
extern	BOOLEAN	  EqualManifested(OBJECT x, OBJECT y);

/*****  z08.c	  Object Manifest	**************************************/
extern	OBJECT	  ReplaceWithTidy(OBJECT x, int one_word);
extern	float	  GetScaleFactor(OBJECT x);
extern	OBJECT	  Manifest(OBJECT x, OBJECT env, STYLE *style, OBJECT bthr[2],
		    OBJECT fthr[2], OBJECT *target, OBJECT *crs, BOOLEAN ok,
		    BOOLEAN need_expand, OBJECT *enclose, BOOLEAN fcr);

/*****  z09.c	  Closure Expansion	**************************************/
extern	OBJECT	  SearchEnv(OBJECT env, OBJECT sym);
extern	OBJECT	  SetEnv(OBJECT x, OBJECT y);
extern	void	  AttachEnv(OBJECT env, OBJECT x);
extern	OBJECT	  GetEnv(OBJECT x);
extern	OBJECT	  DetachEnv(OBJECT x);
extern	OBJECT	  ClosureExpand(OBJECT x, OBJECT env, BOOLEAN crs_wanted,
		    OBJECT *crs, OBJECT *res_env);
extern	OBJECT	  ParameterCheck(OBJECT x, OBJECT env);

/*****  z10.c	  Cross References	**************************************/
extern	void	  CrossInitModule(void);
extern	void	  CrossInit(OBJECT sym);
extern	OBJECT	  CrossMake(OBJECT sym, OBJECT val, int ctype);
extern	OBJECT	  GallTargEval(OBJECT sym, FILE_POS *dfpos);
extern	void	  CrossAddTag(OBJECT x);
extern	OBJECT	  CrossExpand(OBJECT x, OBJECT env, STYLE *style,
		    OBJECT *crs, OBJECT *res_env);
extern	void	  CrossSequence(OBJECT x);
extern	void	  CrossClose(void);

/*****  z11.c	  Style Service		**************************************/
extern	FULL_CHAR *EchoStyle(STYLE *style);
extern	void	  SpaceChange(STYLE *style, OBJECT x);
extern	void	  BreakChange(STYLE *style, OBJECT x);
extern	void	  YUnitChange(STYLE *style, OBJECT x);
extern	void	  ZUnitChange(STYLE *style, OBJECT x);

/*****  z12.c	  Size Finder		**************************************/
extern	void	  SpannerAvailableSpace(OBJECT y, int dim, FULL_LENGTH *resb,
		     FULL_LENGTH *resf);
extern	OBJECT	  MinSize(OBJECT x, int dim, OBJECT *extras);

/*****  z13.c	  Object Breaking	**************************************/
extern	OBJECT	  BreakObject(OBJECT x, CONSTRAINT *c);

/*****  z14.c	  Object Filling        **************************************/
extern	OBJECT	  FillObject(OBJECT x, CONSTRAINT *c, OBJECT multi,
		     BOOLEAN can_hyphenate, BOOLEAN allow_shrink,
		     BOOLEAN extend_unbreakable, BOOLEAN *hyph_used);

/*****  z15.c	  Size Constraints	**************************************/
extern	void	  MinConstraint(CONSTRAINT *xc, CONSTRAINT *yc);
extern	void	  SetSizeToMaxForwardConstraint(FULL_LENGTH *b, FULL_LENGTH *f,
		    CONSTRAINT *c);
extern	void	  EnlargeToConstraint(FULL_LENGTH *b, FULL_LENGTH *f,
		    CONSTRAINT *c);
extern	int	  ScaleToConstraint(FULL_LENGTH b, FULL_LENGTH f,
		    CONSTRAINT *c);
extern	void	  InvScaleConstraint(CONSTRAINT *yc, FULL_LENGTH sf,
		    CONSTRAINT*xc);
extern	void	  RotateConstraint(CONSTRAINT *c, OBJECT y, FULL_LENGTH angle,
		    CONSTRAINT *hc, CONSTRAINT *vc, int dim);
extern	BOOLEAN	  InsertScale(OBJECT x, CONSTRAINT *c);
extern	void	  Constrained(OBJECT x, CONSTRAINT *xc, int dim, OBJECT *why);
extern	FULL_CHAR *EchoConstraint(CONSTRAINT *c);
extern	void	  DebugConstrained(OBJECT x);

/*****  z16.c	  Size Adjustments	**************************************/
extern	FULL_LENGTH	  FindShift(OBJECT x, OBJECT y, int dim);
extern	void	  SetNeighbours(OBJECT link, BOOLEAN ratm, OBJECT *pg,
		    OBJECT *pdef, OBJECT *sg, OBJECT *sdef, int *side);
extern	void	  AdjustSize(OBJECT x, FULL_LENGTH b, FULL_LENGTH f, int dim);

/*****  z17.c	  Gap Widths		**************************************/
extern	int	  GetWidth(OBJECT x, STYLE *style);
extern	void	  GetGap(OBJECT x, STYLE *style, GAP *res_gap,
		    unsigned *res_inc);
extern	FULL_LENGTH  MinGap(FULL_LENGTH a, FULL_LENGTH b, FULL_LENGTH c, GAP *xgap);
extern	FULL_LENGTH  ExtraGap(FULL_LENGTH a, FULL_LENGTH b, GAP *xgap, int dir);
extern	FULL_LENGTH  ActualGap(FULL_LENGTH a, FULL_LENGTH b, FULL_LENGTH c,
		       GAP *xgap, FULL_LENGTH f, FULL_LENGTH mk);
extern	FULL_CHAR *EchoGap(GAP *xgap);

/*****  z18.c	  Galley Transfer	**************************************/
extern	STYLE	  InitialStyle;
extern	CONTEXT	  InitialContext;
extern	OBJECT	  InitialEnvironment;
extern	void	  TransferInit(OBJECT InitEnv);
extern	OBJECT	  TransferBegin(OBJECT x);
extern	void	  TransferComponent(OBJECT x);
extern	void	  TransferEnd(OBJECT x);
extern	void	  TransferClose(void);

/*****  z19.c	  Galley Attaching	**************************************/
extern	void	  DetachGalley(OBJECT hd);
extern	OBJECT	  SearchGalley(OBJECT start, OBJECT sym, BOOLEAN forwards,
		    BOOLEAN subgalleys, BOOLEAN closures, BOOLEAN input);
extern	int	  AttachGalley(OBJECT hd, OBJECT *inners, OBJECT *suspend_pt);

/*****  z20.c	  Galley Flushing	**************************************/
extern	FULL_CHAR *DebugInnersNames(OBJECT inners);
extern	void	  FlushGalley(OBJECT hd);

/***    z21.c	  Galley Maker		**************************************/
extern	void	  SizeGalley(OBJECT hd, OBJECT env, BOOLEAN rows,
		    BOOLEAN joined, BOOLEAN nonblock, BOOLEAN trig,
		    STYLE *style, CONSTRAINT *c, OBJECT target,
		    OBJECT *dest_index, OBJECT *recs, OBJECT *inners,
		    OBJECT enclose);

/***    z22.c	  Galley Service	**************************************/
extern	void	  PromoteInit(void);
extern	void	  ClearHeaders(OBJECT hd);
extern	void	  Interpose(OBJECT z, int typ, OBJECT x, OBJECT y);
extern	void	  FlushInners(OBJECT inners, OBJECT hd);
extern	void	  ExpandRecursives(OBJECT recs);
extern	void	  HandleHeader(OBJECT hd, OBJECT header);
extern	void	  Promote(OBJECT hd, OBJECT stop_link, OBJECT dest_index,
		    BOOLEAN join_after);
extern	void	  KillGalley(OBJECT hd, BOOLEAN optimize);
extern	void	  FreeGalley(OBJECT hd, OBJECT stop_link, OBJECT *inners,
		    OBJECT relocate_link, OBJECT sym);
extern	void	  SetTarget(OBJECT hd);
extern	int	  CheckComponentOrder(OBJECT preceder, OBJECT follower);

/*****  z23.c	  Galley Printer	**************************************/
extern	OBJECT	  FixAndPrintObject(OBJECT x, FULL_LENGTH xmk, FULL_LENGTH xb,
		    FULL_LENGTH xf, int dim, BOOLEAN suppress, FULL_LENGTH pg,
		    int count, FULL_LENGTH *actual_back, FULL_LENGTH *actual_fwd);

/*****  z24.c	  Print Service         **************************************/
extern	char	  *EightBitToPrintForm[];

/*****  z25.c	  Object Echo	        **************************************/
extern	FULL_CHAR *EchoObject(OBJECT x);
extern	void	  DebugObject(OBJECT x);
extern	FULL_CHAR *EchoIndex(OBJECT index);
extern	void	  DebugGalley(OBJECT hd, OBJECT pinpt, int indent);

/*****  z26.c	  Echo Service	        **************************************/
extern	void	  BeginString(void);
extern	void	  AppendString(FULL_CHAR *str);
extern	FULL_CHAR *EndString(void);
extern	FULL_CHAR *EchoLength(int len);
extern	FULL_CHAR *Image(unsigned int c);
extern	void	  SetLengthDim(int dim);

/*****	z27.c	  Debug Service		**************************************/
#if DEBUG_ON
extern	void	  DebugInit(FULL_CHAR *str);
extern	void	  Debug(int category, int urgency, char *str, ...);
extern	void	  ProfileOn(char *str);
extern	void	  ProfileOff(char *str);
extern	void	  ProfilePrint(void);
#endif

/*****	z28.c	  Error Service		**************************************/
extern	void	  ErrorInit(void);
extern	void	  ErrorSetFile(FULL_CHAR *str);
extern	BOOLEAN	  ErrorSeen(void);
extern	void	  EnterErrorBlock(BOOLEAN ok_to_print);
extern	void	  LeaveErrorBlock(BOOLEAN commit);
extern	void	  CheckErrorBlocks(void);
extern	POINTER	  Error(int set_num, int msg_num, char *str, int etype,
		    FILE_POS *pos, ...);

/*****  z29.c	  Symbol Table		**************************************/
extern	void	  InitSym(void);
extern	void	  PushScope(OBJECT x, BOOLEAN npars, BOOLEAN vis);
extern	void	  PopScope(void);
extern	void	  SuppressVisible(void);
extern	void	  UnSuppressVisible(void);
extern	void	  SuppressScope(void);
extern	void	  UnSuppressScope(void);
extern	void	  SwitchScope(OBJECT sym);
extern	void	  UnSwitchScope(OBJECT sym);
extern	void	  BodyParAllowed(void);
extern	void	  BodyParNotAllowed(void);
extern	OBJECT	  GetScopeSnapshot(void);
extern	void	  LoadScopeSnapshot(OBJECT ss);
extern	void	  ClearScopeSnapshot(OBJECT ss);
extern	OBJECT	  InsertSym(FULL_CHAR *str, unsigned char xtype,
		    FILE_POS *xfpos, unsigned char xprecedence,
		    BOOLEAN xindefinite, BOOLEAN xrecursive,
		    unsigned xpredefined, OBJECT xenclosing, OBJECT xbody);
extern	void	  InsertAlternativeName(FULL_CHAR *str, OBJECT s,
		    FILE_POS *xfpos);
extern	OBJECT	  SearchSym(FULL_CHAR *str, int len);
extern	FULL_CHAR *SymName(OBJECT s);
extern	FULL_CHAR *FullSymName(OBJECT x, FULL_CHAR *str);
extern	OBJECT	  ChildSym(OBJECT s, unsigned typ);
extern	OBJECT	  ChildSymWithCode(OBJECT s, unsigned char code);
extern	void	  CheckSymSpread(void);
extern	void	  DeleteEverySym(void);
extern	void	  DebugScope(void);

/*****  z30.c	  Symbol Uses		**************************************/
extern	void	  InsertUses(OBJECT x, OBJECT y);
extern	void	  FlattenUses(void);
extern	BOOLEAN	  SearchUses(OBJECT x, OBJECT y);
extern	OBJECT	  FirstExternTarget(OBJECT sym, OBJECT *cont);
extern	OBJECT	  NextExternTarget(OBJECT sym, OBJECT *cont);

/*****  z31.c	  Memory Allocator	**************************************/
extern	void	  DebugRegisterUsage(int typ, int delta_num, int delta_size);
extern	void	  DebugMemory(void);
extern	void	  MemInit(void);
extern	OBJECT	  GetMemory(int siz, FILE_POS *pos);
extern	OBJECT	  zz_free[];
extern	unsigned char	zz_lengths[];
extern	int	  zz_newcount;
extern	int	  zz_disposecount;
extern	int	  zz_listcount;
extern	OBJECT	  zz_hold;
extern	OBJECT	  zz_tmp;
extern	OBJECT	  zz_res;
extern	int	  zz_size;
extern	OBJECT	  xx_link, xx_tmp;
extern	OBJECT	  xx_hold, xx_res;

/*****  z32.c	  Counter Service           **********************************/
extern	OBJECT	  Next(OBJECT x, int inc, BOOLEAN *done);

/*****  z33.c	  Database Service	**************************************/
extern	OBJECT	  OldCrossDb;
extern	OBJECT	  NewCrossDb;
extern	void	  DbInit(void);
extern	OBJECT	  DbCreate(OBJECT x);
extern	void	  DbInsert(OBJECT db, BOOLEAN gall, OBJECT sym, FULL_CHAR *tag,
		    FILE_POS *tagfpos, FULL_CHAR *seq, FILE_NUM dfnum,
		    long dfpos, int dlnum, BOOLEAN check);
extern	void	  DbConvert(OBJECT db, BOOLEAN full_name);
extern	void	  DbClose(OBJECT db);
extern	OBJECT	  DbLoad(OBJECT stem, int fpath, BOOLEAN create, OBJECT symbs,
		    BOOLEAN in_memory);
extern	BOOLEAN	  DbRetrieve(OBJECT db, BOOLEAN gall, OBJECT sym,
		    FULL_CHAR *tag, FULL_CHAR *seq, FILE_NUM *dfnum,
		    long *dfpos, int *dlnum, long *cont);
extern	BOOLEAN	  DbRetrieveNext(OBJECT db, BOOLEAN *gall, OBJECT *sym,
		    FULL_CHAR *tag, FULL_CHAR *seq, FILE_NUM *dfnum,
		    long *dfpos, int *dlnum, long *cont);

/*****  z34.c	  Rotation Service    	**************************************/
extern	void	  RotateSize(FULL_LENGTH *xcb, FULL_LENGTH *xcf,
		    FULL_LENGTH *xrb, FULL_LENGTH *xrf, OBJECT y,
		    FULL_LENGTH theta);

/*****  z35.c	  Time Keeper     	**************************************/
extern	FULL_CHAR *TimeString(void);
extern	void	  InitTime(void);
extern	OBJECT	  MomentSym;
extern	OBJECT	  StartMoment(void);

/*****  z36.c	  Hyphenation     	**************************************/
extern	void	  HyphInit(void);
extern	BOOLEAN	  ReadHyphTable(LANGUAGE_NUM lnum);
extern	OBJECT	  Hyphenate(OBJECT x);

/*****  z37.c	  Font Service           *************************************/
extern	OBJECT	  FontDefSym;
extern	FONT_INFO *finfo;
extern	int	  font_curr_page;
extern	void	  FontInit(void);
extern	void	  FontChange(STYLE *style, OBJECT x);
extern	FULL_LENGTH FontKernLength(FONT_NUM fnum, FULL_CHAR *unacc_map,
  FULL_CHAR ch1, FULL_CHAR ch2);
extern	void	  FontWordSize(OBJECT x);
extern	FULL_LENGTH  FontSize(FONT_NUM fnum, OBJECT x);
extern	FULL_LENGTH  FontHalfXHeight(FONT_NUM fnum);
extern	MAPPING	  FontMapping(FONT_NUM fnum, FILE_POS *xfpos);
extern	FULL_CHAR *FontName(FONT_NUM fnum);
extern	FULL_CHAR *FontFamily(FONT_NUM fnum);
extern	FULL_CHAR *FontFace(FONT_NUM fnum);
extern	FULL_CHAR *FontFamilyAndFace(FONT_NUM fnum);
extern	void	  FontPrintAll(FILE *fp);
extern	void	  FontPrintPageSetup(FILE *fp);
extern	void	  FontPrintPageResources(FILE *fp);
extern	void	  FontAdvanceCurrentPage(void);
extern	void	  FontPageUsed(OBJECT face);
extern	BOOLEAN	  FontNeeded(FILE *fp);
extern	FULL_LENGTH FontGlyphHeight(FONT_NUM fnum, FULL_CHAR chr);
extern	FULL_LENGTH FontGlyphWidth(FONT_NUM fnum, FULL_CHAR chr);

/*****  z38.c	  Character Mappings    **************************************/
extern	MAP_VEC	  MapTable[];
extern	void	  MapInit(void);
extern	MAPPING	  MapLoad(OBJECT filename, BOOLEAN recoded);
extern	FULL_CHAR MapCharEncoding(FULL_CHAR *str, MAPPING m);
extern	FULL_CHAR *MapEncodingName(MAPPING m);
extern	void	  MapPrintEncodings(void);
extern	void	  MapEnsurePrinted(MAPPING m, int curr_page);
extern	void	  MapPrintPSResources(FILE *fp);
extern	OBJECT	  MapSmallCaps(OBJECT x, STYLE *style);
extern	BOOLEAN	  MapIsLowerCase(FULL_CHAR ch, MAPPING m);


/*****  z39.c	  String Handler        **************************************/
#define		  AsciiToFull(x)	( (FULL_CHAR *) (x) )
#define		  StringEqual(a, b)	(strcmp((char *)(a), (char *)(b))==0)
extern int	  strcollcmp(char *a, char *b);
#define		  TabbedStringLessEqual(a, b) \
		    ( UseCollate ? strcollcmp((char *)(a),(char *)(b)) <= 0 \
				 : strcmp((char *)(a),(char *)(b)) <= 0 )
#define		  StringCat(a, b)	strcat((char *)(a),(char *)(b))
#define		  StringCopy(a, b)	strcpy((char *)(a),(char *)(b))
#define		  StringLength(a)	strlen((char *)(a))
#define		  StringFOpen(a, b)	fopen( (char *) (a), (b) )
#define		  StringFPuts(a, b)	fputs( (char *) (a), (b) )
#define		  StringRemove(a)	remove((char *)(a))
#define		  StringRename(a, b)	rename((char *)(a),(char *)(b))
extern	BOOLEAN	  StringBeginsWith(FULL_CHAR *str, FULL_CHAR *pattern);
extern	BOOLEAN	  StringBeginsWithWord(FULL_CHAR *str, FULL_CHAR *pattern);
extern	BOOLEAN	  StringEndsWith(FULL_CHAR *str, FULL_CHAR *pattern);
extern	BOOLEAN	  StringContains(FULL_CHAR *str, FULL_CHAR *pattern);
extern	FULL_CHAR *StringInt(int i);
extern	FULL_CHAR *StringFiveInt(int i);
extern	FULL_CHAR *StringQuotedWord(OBJECT x);

/*****  z40.c	  Filter Handler        **************************************/
extern	void	  FilterInit(void);
extern	OBJECT	  FilterCreate(BOOLEAN use_begin, OBJECT act, FILE_POS *xfpos);
extern	void	  FilterSetFileNames(OBJECT x);
extern	OBJECT	  FilterExecute(OBJECT x, FULL_CHAR *command, OBJECT env);
extern	void	  FilterWrite(OBJECT x, FILE *fp, int *linecount);
extern	void	  FilterScavenge(BOOLEAN all);

/*****  z41.c	  Object Input-Output   **************************************/
extern	void	  ReadFromFileInit(void);
extern	OBJECT	  ReadFromFile(FILE_NUM fnum, long pos, int lnum);
extern	void	  AppendToFile(OBJECT x, FILE_NUM fnum, int *pos, int *lnum);
extern	void	  CloseFiles(void);

/*****  z42.c	  Colour Service        **************************************/
extern	void	  ColourInit(void);
extern	void	  ColourChange(STYLE *style, OBJECT x);
extern	void	  ColourUnderlineChange(STYLE *style, OBJECT x);
extern	FULL_CHAR *ColourCommand(COLOUR_NUM cnum);

/*****  z43.c	  Language Service      **************************************/
extern	void	  LanguageInit(void);
extern	BOOLEAN	  LanguageWordEndsSentence(OBJECT wd, BOOLEAN lc_prec);
extern	void	  LanguageDefine(OBJECT names, OBJECT hyph_file);
extern	void	  LanguageChange(STYLE *style, OBJECT x);
extern	FULL_CHAR *LanguageString(LANGUAGE_NUM lnum);
extern	OBJECT	  LanguageHyph(LANGUAGE_NUM lnum);
extern	BOOLEAN	  LanguageSentenceEnds[];

/*****  z44.c	  Vertical Hyphenation  **************************************/
extern	BOOLEAN	  VerticalHyphenate(OBJECT y);
extern	OBJECT	  ConvertGalleyList(OBJECT x);
extern	OBJECT	  BuildEnclose(OBJECT hd);

/*****  z45.c	  External Sort         **************************************/
extern	int	  ReadOneLine(FILE *fp, FULL_CHAR *buff, int buff_len);
extern	int	  ReadOneBinaryLine(FILE *fp, FULL_CHAR *buff, int buff_len,
                    int *count, long *remaining_len);
extern	LINE	  *ReadLines(FILE *fp, FULL_CHAR *fname, FULL_CHAR *first_line, int *len);
extern	void	  WriteLines(FILE *fp, LINE *lines, int len);
extern	void	  SortLines(LINE *lines, int lines_len);
extern	void	  SortFile(FULL_CHAR *infile, FULL_CHAR *outfile);

/*****  z46.c	  Optimal Galleys       **************************************/
extern	BOOLEAN	  FindOptimize(OBJECT x, OBJECT env);
extern	void	  SetOptimize(OBJECT hd, STYLE *style);
extern	void	  GazumpOptimize(OBJECT hd, OBJECT dest);
extern	void	  CalculateOptimize(OBJECT hd);
extern	void	  DebugOptimize(OBJECT hd);

/*****  z47.c	  Environment Table     **************************************/
extern	void	  EnvInit(void);
extern	BOOLEAN	  EnvWriteRetrieve(OBJECT env, FILE_NUM fnum, int *offset,
		    int *lnum);
extern	void	  EnvWriteInsert(OBJECT env, FILE_NUM fnum, int offset,int lnum);
extern	BOOLEAN	  EnvReadRetrieve(FILE_NUM fnum, int offset, OBJECT *env);
extern	void	  EnvReadInsert(FILE_NUM fnum, int offset, OBJECT env);
extern	void	  EnvDebug(void);

/*****  z48.c	  PDF back end (old)    **************************************/
extern	void      PDFFile_Init(FILE* in_fp, int in_h_bound, int in_v_bound,
				int in_IN, int in_CM, int in_PT, int in_EM);
extern	void      PDFFile_BeginFontEncoding(FILE* in_fp,
				const char* in_encoding_name);
extern	void      PDFFile_EndFontEncoding(FILE* in_fp);
extern	void      PDFFile_Cleanup(FILE* in_fp);
extern	void      PDFPage_Init(FILE* in_fp, float in_scale_factor,
				int in_line_width);
extern	void      PDFPage_Cleanup(FILE* in_fp);
extern	void	  PDFPage_Write(FILE* in_fp, char* in_str);
extern	void      PDFPage_Push(FILE* in_fp);
extern	void      PDFPage_Pop(FILE* in_fp);
extern	void	  PDFPage_Scale(FILE* in_fp, float in_h_scale_factor,
				float in_v_scale_factor);
extern	void	  PDFPage_Translate(FILE* in_fp, float in_delta_h,
				float in_delta_v);
extern	void	  PDFPage_Rotate(FILE* in_fp, float in_angle_in_radians);
extern	void	  PDFPage_SetVars(int xsize, int ysize, int xmark, int ymark,
				int loutf, int loutv, int louts);
extern	void	  PDFPage_WriteGraphic(FILE* in_fp, FULL_CHAR* in_str);
extern	void	  PDFPage_PrintUnderline(FILE* in_fp, int in_x1, int in_x2,
				int in_y, int in_thickness);

extern	void      PDFFont_AddFont(
				FILE* in_fp,
				const FULL_CHAR* in_short_font_name,
				const FULL_CHAR* in_real_font_name,
				const FULL_CHAR* in_font_encoding_name);
extern	void      PDFFont_Set(FILE* in_fp, FULL_LENGTH in_font_size,
				FULL_CHAR * in_short_font_name);
extern	void    PDFText_OpenXY(FILE* in_fp, int hpos, int vpos);
extern	void    PDFText_OpenX(FILE* in_fp, int hpos);
extern	void    PDFText_Open(FILE* in_fp);
extern	void    PDFText_Kern(FILE* in_fp, int in_kern);
extern	void    PDFText_Close(FILE* in_fp);
extern	BOOLEAN PDFHasValidTextMatrix(void);

/*****  z49.c	  PostScript back end   **************************************/
extern	BACK_END  PS_BackEnd;
extern	BACK_END  PS_NullBackEnd;
extern	void	  PS_IncGRepeated(OBJECT x);
/* extern	int	  PS_FindIncGRepeated(OBJECT x, int typ); */
/* extern	void	  PS_PrintEPSFile(FILE *fp, FILE_POS *pos); */
extern	BOOLEAN	  PS_FindBoundingBox(FILE *fp, FILE_POS *pos, FULL_LENGTH *llx,
		    FULL_LENGTH *lly, FULL_LENGTH *urx, FULL_LENGTH *ury);

/*****  z50.c	  PDF back end (new)    **************************************/
extern	BACK_END  PDF_BackEnd;		/* PDF back end record               */

/*****  z51.c	  Plain text back end   **************************************/
extern	BACK_END  Plain_BackEnd;	/* Plain Text back end record        */
extern	BACK_END  Plain_NullBackEnd;	/* Plain Text null back end record   */
extern	FULL_LENGTH PlainCharWidth;	/* character width                   */
extern	FULL_LENGTH PlainCharHeight;	/* character height		     */
extern	BOOLEAN	  PlainFormFeed;	/* true if using \f		     */

/*****  z52.c	  Texture Service        **************************************/
extern	BOOLEAN	  UseTexture;
extern	void	  TextureInit(void);
extern	void	  TextureChange(STYLE *style, OBJECT x);
extern	FULL_CHAR *TextureCommand(TEXTURE_NUM pnum);

/*@::assert(), debug(), debug flags@******************************************/
/*                                                                           */
/*  ASSERT AND DEBUG CODE                                                    */
/*                                                                           */
/*****************************************************************************/

#if ASSERT_ON
#define assert(c, m)							\
   { if( !(c) )  Error(1, 2, "assert failed in %s", INTERN, no_fpos, m); }
#define assert1(c, m, p1)						\
   { if( !(c) )  Error(1, 3, "assert failed in %s %s", INTERN,no_fpos,m, p1); }
#else
#define assert(c, m)
#define assert1(c, m, p1)
#endif

#if DEBUG_ON

struct dbs
{	char	*flag;			/* external names for debug flags    */
	BOOLEAN	on[3];			/* the debug flags                   */
};
extern	struct dbs 	dbg[];

/* debug routines */
#define debug0(cat, urg, str)                				\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str); }
#define debug1(cat, urg, str, p1)					\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1); }
#define debug2(cat, urg, str, p1, p2)					\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2); }
#define debug3(cat, urg, str, p1, p2, p3)				\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3); }
#define debug4(cat, urg, str, p1, p2, p3, p4)				\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4); }
#define debug5(cat, urg, str, p1, p2, p3, p4, p5)			\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4, p5); }
#define debug6(cat, urg, str, p1, p2, p3, p4, p5, p6)			\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4, p5, p6); }
#define debug7(cat, urg, str, p1, p2, p3, p4, p5, p6, p7)		\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2, p3, p4, p5,p6,p7); }
#define debug8(cat, urg, str, p1, p2, p3, p4, p5, p6, p7, p8)		\
    { if( dbg[cat].on[urg] ) Debug(cat, urg, str, p1, p2,p3,p4,p5,p6,p7,p8); }
#define	ifdebug(cat, urg, x)						\
    { if( dbg[cat].on[urg] ) { x; } }

#define debugcond0(cat, urg, cond, str)                			\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str); }
#define debugcond1(cat, urg, cond, str, p1)				\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1); }
#define debugcond2(cat, urg, cond, str, p1, p2)				\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2); }
#define debugcond3(cat, urg, cond, str, p1, p2, p3)			\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2, p3); }
#define debugcond4(cat, urg, cond, str, p1, p2, p3, p4)			\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2, p3, p4); }
#define debugcond5(cat, urg, cond, str, p1, p2, p3, p4, p5)		\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2, p3, p4, p5);}
#define debugcond6(cat, urg, cond, str, p1, p2, p3, p4, p5, p6)		\
    { if( dbg[cat].on[urg] && cond ) Debug(cat, urg, str, p1, p2,p3,p4,p5,p6);}
#define	ifdebugcond(cat, urg, cond, x)					\
    { if( dbg[cat].on[urg] && cond ) { x; } }
#define	debug_init(str)							\
    DebugInit(str)

/* debug styles */
#define	D	 0
#define	DD	 1
#define	DDD	 2

/* debug flags */
#define	DSP	 1		/*  z01.c   -dsp   Supervise                 */
#define	DLA	 2		/*  z02.c   -dla   Lexical Analyser          */
#define	DFS	 3		/*  z03.c   -dfs   File Service              */
#define	DTS	 4		/*  z04.c   -dts   Token Service             */
#define	DRD	 5		/*  z05.c   -drd   Read Definitions          */
#define	DOP	 6		/*  z06.c   -dop   Object Parser             */
#define	DOS	 7		/*  z07.c   -dos   Object Service            */
#define	DOM	 8		/*  z08.c   -dom   Object Manifest           */
#define	DCE	 9		/*  z09.c   -dce   Closure Expansion         */
#define	DCR	10		/*  z10.c   -dcr   Cross References	     */
#define	DSS	11		/*  z11.c   -dss   Style Service	     */
#define	DSF	12		/*  z12.c   -dsf   Size Finder               */
#define	DOB	13		/*  z13.c   -dob   Object Breaking	     */
#define	DOF	14		/*  z14.c   -dof   Object Filling	     */
#define	DSC	15		/*  z15.c   -dsc   Size Constraints          */
#define	DSA	16		/*  z16.c   -dsa   Size Adjustments	     */
#define	DGW	17		/*  z17.c   -dgw   Gap Widths                */
#define	DGT	18		/*  z18.c   -dgt   Galley Transfer           */
#define	DGA	19		/*  z19.c   -dgf   Galley Attaching          */
#define	DGF	20		/*  z20.c   -dgf   Galley Flushing           */
#define	DGM	21		/*  z21.c   -dgm   Galley Maker              */
#define	DGS	22		/*  z22.c   -dgs   Galley Service            */
#define	DGP	23		/*  z23.c   -dgp   Galley Printer            */
#define	DPS	24		/*  z24.c   -dps   Print Service             */
#define	DOE	25		/*  z25.c   -doe   Object Echo               */
#define	DES	26		/*  z26.c   -des   Echo Service		     */
#define	DZZ	27		/*  z27.c   -dzz   Debug Service             */
#define	DYY	28		/*  z28.c   -dyy   Error Service             */
#define	DST	29		/*  z29.c   -dst   Symbol Table              */
#define	DSU	30		/*  z30.c   -dsu   Symbol Uses               */
#define	DMA	31		/*  z31.c   -dma   Memory Allocator          */
#define	DCS	32		/*  z32.c   -dcs   Counter Service           */
#define	DBS	33		/*  z33.c   -dbs   Database Service          */
#define	DRS	34		/*  z34.c   -drs   Rotation Service          */
#define	DTK	35		/*  z35.c   -dtk   Time Keeper               */
#define	DHY	36		/*  z36.c   -dhy   Hyphenation               */
#define	DFT	37		/*  z37.c   -dft   Font Service              */
#define	DCM	38		/*  z38.c   -dcm   Character Mapping         */
#define	DSH	39		/*  z39.c   -dsh   String Handler            */
#define	DFH	40		/*  z40.c   -dsh   Filter Handler            */
#define	DIO	41		/*  z41.c   -dio   Object Input-Output       */
#define	DCO	42		/*  z42.c   -dco   Colour Service            */
#define	DLS	43		/*  z43.c   -dls   Language Service          */
#define	DVH	44		/*  z44.c   -dvh   Vertical Hyphenation      */
#define	DEX	45		/*  z45.c   -dex   External Sort             */
#define	DOG	46		/*  z46.c   -dex   Optimal Galleys           */
#define	DET	47		/*  z47.c   -det   Environment Table         */
#define	DPD	48		/*  z48.c   -dpd   PDF Back End (old)        */
#define	DPO	49		/*  z49.c   -dpo   PostScript Back End       */
#define	DPF	50		/*  z50.c   -dpf   PDF Back End              */
#define	DPT	51		/*  z51.c   -dpt   Plain Text Back End       */
#define	DTX	52		/*  z52.c   -dtx   Texture Service           */
#define	DPP	53		/*          -dpp   Profiling                 */
#define	ANY	54		/*          -d     any                       */

#else
#define ifdebug(cat, urg, x)
#define debug0(cat, urg, str)
#define debug1(cat, urg, str, p1)
#define debug2(cat, urg, str, p1, p2)
#define debug3(cat, urg, str, p1, p2, p3)
#define debug4(cat, urg, str, p1, p2, p3, p4)
#define debug5(cat, urg, str, p1, p2, p3, p4, p5)
#define debug6(cat, urg, str, p1, p2, p3, p4, p5, p6)
#define debug7(cat, urg, str, p1, p2, p3, p4, p5, p6, p7)
#define debug8(cat, urg, str, p1, p2, p3, p4, p5, p6, p7, p8)

#define debugcond0(cat, urg, cond, str)
#define debugcond1(cat, urg, cond, str, p1)
#define debugcond2(cat, urg, cond, str, p1, p2)
#define debugcond3(cat, urg, cond, str, p1, p2, p3)
#define debugcond4(cat, urg, cond, str, p1, p2, p3, p4)
#define debugcond5(cat, urg, cond, str, p1, p2, p3, p4, p5)
#define debugcond6(cat, urg, cond, str, p1, p2, p3, p4, p5, p6)
#define	ifdebugcond(cat, urg, cond, x)
#define	debug_init(str)	Error(1, 4, "%s - debug flags not implemented", \
	FATAL, no_fpos, str)
#endif