summaryrefslogtreecommitdiff
path: root/support/dktools/dk3types.h
blob: 1e2a80816c29c3a03cf5323e068f258a5757c275 (plain)
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

/**	@file	dk3types.h	Type definitions for the dk3 library.
 */

#ifndef DK3_TYPES_H_INCLUDED
/** Avoid multiple file inclusions. */
#define DK3_TYPES_H_INCLUDED 1

#include <dk3conf.h>

#if DK3_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if DK3_HAVE_STDINT_H
#include <stdint.h>
#endif
#if DK3_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#if DK3_HAVE_SIGNAL_H
#include <signal.h>
#endif
#if DK3_HAVE_WCHAR_H
#include <wchar.h>
#endif
#if DK3_HAVE_TERMIOS_H
#include <termios.h>
#endif
#if DK3_HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#if DK3_HAVE_SYS_TTOLD_H
#include <sys/ttold.h>
#endif
#if DK3_HAVE_ZLIB_H
#include <zlib.h>
#endif

#ifndef DK3_CHAR_SIZE
#if DK3_ON_WINDOWS && (defined(_UNICODE))
/**	Specify default character size 16 bit.
*/
#define	DK3_CHAR_SIZE	2
#else
/**	Specify default character size 8 bit.
*/
#define	DK3_CHAR_SIZE	1
#endif
#endif


/*
	Simple data types.
*/

/**	A 8-bit unsigned int  type.
*/
typedef unsigned char	dk3_u8_t;

/**	An 8-bit signed int type.
*/
typedef signed char dk3_i8_t;

/**	A 8-bit character type.
*/
typedef char /*^unsignedintegraltype^*/	dk3_c8_t;

/**	A 16-bit unsigned int type.
*/
typedef	unsigned short	dk3_u16_t;

/**	A 16-bit signed int type.
*/
typedef short dk3_i16_t;

/**	A 16 bit character type (used on Windows).
*/
#if DK3_SIZEOF_WCHAR_T == 2
typedef wchar_t		/*^unsignedintegraltype^*/	dk3_c16_t;
#else
typedef unsigned short	/*^unsignedintegraltype^*/	dk3_c16_t;
#endif

/**	A 32-bit character/unsigned int type (wchar_t on UNIX, not used).
*/
typedef unsigned long dk3_u32_t;

/**	A 32-bit signed int type.
*/
typedef long dk3_i32_t;

/**	A 32-bit character type (used i.e. by X11).
*/
#if DK3_SIZEOF_WCHAR_T == 4
typedef	wchar_t	      /*^unsignedintegraltype^*/	dk3_c32_t;
#else
#if DK3_SIZEOF_INT >= 4
typedef unsigned      /*^unsignedintegraltype^*/	dk3_c32_t;
#else
typedef unsigned long /*^unsignedintegraltype^*/	dk3_c32_t;
#endif
#endif



#if DK3_CHAR_SIZE > 1
#if defined(DK3_SIZEOF_WCHAR_T)
#if DK3_CHAR_SIZE == DK3_SIZEOF_WCHAR_T
/**	Text character type.
*/
typedef	wchar_t		/*^unsignedintegraltype^*/	dkChar;
/**	Macro to switch text literals between 8-bit and 16-bit text.
*/
#define	dkT(s)		L ## s
/**	Macro to switch the main function between 8 and 16 bit.
*/
#define	DK3_MAIN	int wmain(int argc, wchar_t *argv[])
#else
/* if DK3_CHAR_SIZE == DK3_SIZEOF_WCHAR_T */
#if DK3_CHAR_SIZE > 2
/**	Text character type.
*/
typedef	dk3_c32_t	/*^unsignedintegraltype^*/	dkChar;
#error	"Can not use prefix L to specify dkChar string literals!"
#error	"Can not define DK3_MAIN to dkChar!"
#else
/* if DK3_CHAR_SIZE > 2 */
/**	Text character type.
*/
typedef	dk3_c16_t	/*^unsignedintegraltype^*/	dkChar;
#error	"Can not use prefix L to specify dkChar string literals!"
#error	"Can not define DK3_MAIN to dkChar!"
#endif
/* if DK3_CHAR_SIZE > 2 */
#endif
/* if DK3_CHAR_SIZE == DK3_SIZEOF_WCHAR_T */
#else
/* if defined(DK3_SIZEOF_WCHAR_T) */
#error	"Missing definition for DK3_SIZEOF_WCHAR_T!"
#endif
/* if defined(DK3_SIZEOF_WCHAR_T) */
#if !DK3_ON_WINDOWS
#error "Usable support for UNICODE/MBCS is available on Windows platforms only!"
#endif
/* if !DK3_ON_WINDOWS */
#else
/* if DK3_CHAR_SIZE > 1 */
/* +++ DK3_CHAR_SIZE == 1 */
/**	Text character type.
*/
typedef	char		/*^unsignedintegraltype^*/	dkChar;
/**	Macro to switch the main function between 8 and 16 bit.
*/
#define	dkT(s)		s
/**	Macro to switch the main function between 8 and 16 bit.
*/
#define	DK3_MAIN	int main(int argc, char *argv[])
/* --- DK3_CHAR_SIZE == 1 */
#endif
/* if DK3_CHAR_SIZE > 1 */



#if DK3_HAVE_INTMAX_T

/**	Maximum size integer type.
*/
typedef intmax_t			dk3_im_t;

/**	Maximum size unsigned integer type.
*/
typedef uintmax_t			dk3_um_t;

#else

#if DK3_HAVE_LONG_LONG

/**	Maximum size integer type.
*/
typedef long long int			dk3_im_t;

/**	Maximum size unsigned integer type.
*/
typedef long long unsigned		dk3_um_t;

#else

/**	Maximum size integer type.
*/
typedef long int			dk3_im_t;

/**	Maximum size unsigned integer type.
*/
typedef long unsigned			dk3_um_t;

#endif
#endif


/**	Timer.
*/

#if DK3_ON_WINDOWS
/**	Portable type to save a timestamp.
*/
typedef	__time64_t	dk3_time_t;
#else
#if (defined(DK3_HAVE_SYS_TIME_H) || defined(DK3_HAVE_TIME_H)) && defined(DK3_HAVE_TIME)
/**	Portable type to save a timestamp.
*/
typedef	time_t		dk3_time_t;
#else
#error "No mechanism known to obtain current time!"
#endif
#endif



#if DK3_HAVE_LONG_DOUBLE && (DK3_SIZEOF_LONG_DOUBLE > DK3_SIZEOF_DOUBLE)
/**	Most precise double type.
*/
typedef long double	dk3_double_t;
#else
/**	Most precise double type.
*/
typedef double		dk3_double_t;
#endif


#if DK3_ON_WINDOWS
/**	Number of bytes successfully read/written by read()/write().
*/
#define	dk3_rw_res_t	int
#else
#if DK3_HAVE_SSIZE_T
/**	Number of bytes successfully read/written by read()/write().
*/
#define dk3_rw_res_t	ssize_t
#else
/**	Number of bytes successfully read/written by read()/write().
*/
#define	dk3_rw_res_t	int
#endif
#endif

#if DK3_ON_WINDOWS
/**	Buffer size in read()/write().
*/
#define	dk3_rw_arg_t	unsigned int
#else
/**	Buffer size in read()/write().
*/
#define	dk3_rw_arg_t	size_t
#endif


/*
	Structured data types.
*/



/**	Timestamp.
*/
typedef struct _dk3_time_t_ {
  /**	Year.
  */
  int	Y;

  /**	Month.
  */
  int	M;

  /**	Day in month.
  */
  int	D;

  /**	Hours.
  */
  int	h;

  /**	Minutes.
  */
  int	m;

  /**	Seconds.
  */
  int	s;
} dk3_tm_t;



/**	File information.
	When retrieving information about a symbolic link the dk3sf_stat()
	function retrieves information about both the link destination and
	the link itself.
*/
typedef struct {

  /**	Creation timestamp.
  */
  dk3_time_t	cre;

  /**	Modification timestamp.
  */
  dk3_time_t	mod;

  /**	Last access timestamp.
  */
  dk3_time_t	acc;

  /**	Link creation timestamp.
  */
  dk3_time_t	lcre;

  /**	Link modification timestamp.
  */
  dk3_time_t	lmod;

  /**	Link last access timestamp.
  */
  dk3_time_t	lacc;

  /**	User ID.
  */
  dk3_um_t	u;

  /**	Group ID.
  */
  dk3_um_t	g;

  /**	Device number.
  */
  dk3_um_t	device;

  /**	Relative device number.
  */
  dk3_um_t	rdev;

  /**	Inode number.
  */
  dk3_um_t	inode;

  /**	Number of hard links to inode.
  */
  dk3_um_t	nlink;

  /**	File size in bytes.
  */
  dk3_um_t	sz;

  /**	Link user ID.
  */
  dk3_um_t	lu;

  /**	Link group ID.
  */
  dk3_um_t	lg;

  /**	Link device number.
  */
  dk3_um_t	ldevice;

  /**	Link relative device number.
  */
  dk3_um_t	lrdev;

  /**	Link inode number.
  */
  dk3_um_t	linode;

  /**	Number of hard links to the link.
  */
  dk3_um_t	lnlink;

#if DK3_ON_WINDOWS
  long		dwReparse;
#endif

  /**	File type, see @ref filetypes.
  */
  int		ft;

  /**	Permissions, see @ref filepermissions.
  */
  int		perm;

  /**	Link file type.
  */
  int		lft;

  /**	Link permissions.
  */
  int		lperm;

  /**	Link file size.
  */
  dk3_um_t	lsz;

  /**	Additional information about file, see @ref statadditional.
  */
  unsigned char	ai;

#if DK3_ON_WINDOWS
  /**	Reparse point information.
  */
  char		cReparse;
#endif
} dk3_stat_t;




/**	Evaluation result for an object.
*/
typedef union {

    /**	Evaluation to double.
    */
    double d;

    /**	Evaluation to float.
    */
    float f;

    /**	Evaluation to long.
    */
    long l;

    /**	Evaluation to unsigned long.
    */
    unsigned long ul;  

    /**	Evaluation to int.
    */
    int i;

    /**	Evaluation to unsigned int.
    */
    unsigned int ui;  

    /**	Evaluation to short.
    */
    short s;

    /**	Evaluation to unsigned short.
    */
    unsigned short us;

    /**	Evaluation to char.
    */
    char c;

    /**	Evaluation to unsigned char.
    */
    unsigned char uc;
} dk3_object_eval_res_t;


/**	Internal node for dk3_sto_t.
	This structure is used internally by the dksto module.
*/
struct _dk3_sto_node_ {

  /**	Object evaluation of @a o.
  */
  dk3_object_eval_res_t	   v;

  /**	Parent node in tree.
  */
  struct _dk3_sto_node_ *p;

  /**	Left child node (tree) or preceeding node (list).
  */
  struct _dk3_sto_node_ *l;

  /**	Right child node (tree) or following node (list).
  */
  struct _dk3_sto_node_ *r;

  /**	Object to store.
  */
  void                    *o;

  /**	Balance flag (used in trees only).
  */
  short                    b;

  /**	Direction to walk in tree.
  */
  short                    w;	/**< Direction to walk. */
};

/** Internal node for dk3_sto_t.
*/
typedef struct _dk3_sto_node_ dk3_sto_node_t;

/** Pointer to internal node for dk3_sto_t.
*/
typedef dk3_sto_node_t *dk3_sto_node_p;



/**	Evaluation functions.
	These function type are used to evaluate and compare objects
	stored in a sorted dk3_sto_t.
*/

/** Object evaluation function for sorted storage.
*/
typedef char dk3_fct_eval_c_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef unsigned char dk3_fct_eval_uc_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef short dk3_fct_eval_s_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef unsigned short dk3_fct_eval_us_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef int dk3_fct_eval_i_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef unsigned int dk3_fct_eval_ui_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef long dk3_fct_eval_l_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef unsigned long dk3_fct_eval_ul_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef float dk3_fct_eval_f_t(void const *obj, int crit) /*^*/ ;

/** Object evaluation function for sorted storage.
*/
typedef double dk3_fct_eval_d_t(void const *obj, int crit) /*^*/ ;

/** Object comparison function for sorted storage.
    When comparing to objects while inserting a new object into
    a storage both @a o1 and @a o2 are object pointers.
    When this function is called from dk3sto_it_find_like() the
    @a o1 argument is an object pointer from the storage,
    @a o2 is the pointer passed to dk3sto_it_find_like().
*/
typedef int dk3_fct_comp_t(
  /*^null^*/	void const *o1,
  /*^null^*/	void const *o2,
		int crit
) /*^*/ ;



/**	Choice for object evaluation function.
*/
typedef union {

  /** Evaluation function returning a char value.
  */
  dk3_fct_eval_c_t *c;

  /** Evaluation function returning an unsigned char value.
  */
  dk3_fct_eval_uc_t *uc;

  /** Evaluation function returning a short value.
  */
  dk3_fct_eval_s_t *s;

  /** Evaluation function returning an unsigned short value.
  */
  dk3_fct_eval_us_t *us;

  /** Evaluation function returning an int value.
  */
  dk3_fct_eval_i_t *i;

  /** Evaluation function returning an unsigned int value.
  */
  dk3_fct_eval_ui_t *ui;

  /** Evaluation function returning a long value.
  */
  dk3_fct_eval_l_t *l;

  /** Evaluation function returning an unsigned long value.
  */
  dk3_fct_eval_ul_t*ul;

  /** Evaluation function returning a float value.
  */
  dk3_fct_eval_f_t *f;

  /** Evaluation function returning a double value.
  */
  dk3_fct_eval_d_t *d;

  /** Function to compare two objects.
  */
  dk3_fct_comp_t *comp;
} dk3_object_eval_fct_t;



/**	Object storage.
	A storage can be used to store pointers to objects.
*/
typedef struct _dk3_sto_t_ {

  /**	Comparison or evaluation function.
  */
  dk3_object_eval_fct_t	e;

  /**	Application structure for diagnostics.
  */
  void		  	*app;

  /**	Critical path for delete operations.
  */
  dk3_sto_node_p 	*d;

  /**	Root element (tree) or left element (list).
  */
  dk3_sto_node_t 	*r;

  /**	Double-linked list of iterators.
  */
  void              	*i;

  /**	Algorithm selection for comparison or evaluation.
  */
  int 		     	h;

  /**	Criteria for comparison or evaluation.
  */
  int                	c;

  /**	Flag: Use tree, 1=tree, 0=list.
  */
  int		     	t;

  /**	Path length of critical path (number of elements).
  */
  short              	l;
} dk3_sto_t;



/**	Storage iterator.
	This structure can be used to iterate through a dk3_sto_t.
*/
struct _dk3_sto_iterator_ {

  /**	Preceeding iterator in iterator linked list. 
  */
  struct _dk3_sto_iterator_ *l;

  /**	Following iterator in iterator linked list.
  */
  struct _dk3_sto_iterator_ *r;

  /**	Storage owning this iterator.
  */
  dk3_sto_t                *s;

  /**	Current node.
  */
  dk3_sto_node_t           *c;
};
/**	Storage iterator. Can be used to iterate through a dk3_sto_t. */
typedef struct _dk3_sto_iterator_ dk3_sto_it_t;



/**	Key value pair.
*/
typedef struct {
  dkChar	*key;	/**< Key. */
  dkChar	*val;	/**< Value. */
} dk3_key_value_t;



/**	Directory contents.
*/
typedef struct _dk3_dir_t_ {

  /**	Stat buffer for current entry to process.
  */
  dk3_stat_t		stb;

  /**	Storage containing the directory names.
  */
  dk3_sto_t		*sdi;

  /**	Iterator for directory names storage.
  */
  dk3_sto_it_t		*idi;

  /**	Storage containing file names.
  */
  dk3_sto_t		*sfi;

  /**	Iterator for file names storage.
  */
  dk3_sto_it_t		*ifi;

  /**	Directory name.
  */
  dkChar const		*dirname;

  /**	Full path of current entry to process.
  */
  dkChar		*fullname;

  /**	Short name of current entry to process.
  */
  dkChar		*shortname;

  /**	Application used for diagnostics.
  */
  void			*app;

  /**	Number of directories found.
  */
  dk3_um_t		ndir;

  /**	Number of files found.
  */
  dk3_um_t		nfi;
} dk3_dir_t;



/**	Arguments in a stream command API call.
*/
typedef struct {

  /**	Low-level data.
  */
  void	*d;

  /**	Buffer for bytes to read/write.
  */
  char	*b;

  /**	Buffer size (number of bytes to read/write).
  */
  size_t	sz;
} dk3_stream_api_arg_t;



/**	Results of a stream command API call.
*/
typedef struct {

  /**	Number of bytes read.
  */
  size_t	sz;

  /**	Error code DK3_ERROR_xxx, see @ref errorcodes.
  */
  int		ec;
} dk3_stream_api_result_t;



/**	Stream command API.
*/
typedef struct _dk3_stream_api_t_ {

  /**	API call arguments.
  */
  dk3_stream_api_arg_t	arg;

  /**	API call results.
  */
  dk3_stream_api_result_t	res;

  /**	Command to execute, DK3_STREAM_API_xxx, see @ref streamapicommands.
  */
  int	cmd;

  /**	Success flag, 1=success, 0=error.
  */
  int	suc;
} dk3_stream_api_t;

/**	Stream API function type.
*/
typedef void dk3_stream_api_fct_t(dk3_stream_api_t *);

/**	Generic I/O stream.
*/
typedef struct _dk3_stream_t_ {

  /**	Optional application structure for diagnostics.
  */
  void			*app;

  /**	Low-level data.
  */
  void			*d;

  /**	Stream API function.
  */
  dk3_stream_api_fct_t	*f;

  /**	Input buffer.
  */
  char			*ib;

  /**	Output buffer.
  */
  char			*ob;

  /**	Number of bytes written.
  */
  dk3_um_t		wr;

  /**	Size of input buffer.
  */
  size_t		sz_ib;

  /**	Bytes available in input buffer.
  */
  size_t		av_ib;

  /**	Number of bytes already used from input buffer.
  */
  size_t		us_ib;

  /**	Size of output buffer.
  */
  size_t		sz_ob;

  /**	Number of bytes already placed in output buffer.
  */
  size_t		us_ob;

  /**	Output encoding, see @ref fileenc.
  */
  int			oe;

  /**	Usage flags, see @ref streamuseflags.
  */
  int			fl;

  /**	Flag: End of input found.
  */
  int			fe;

  /**	Flag: Reading 0 bytex indicates end of input.
  */
  int			ze;

  /**	Flag: Flush output buffer at end of line.
  */
  int			lf;

  /**	Flag: Error occured.
  */
  int			er;

  /**	Last error occured, see @ref errorcodes.
  */
  int			ec;
} dk3_stream_t;



/**	Application structure.
*/
typedef struct _dk3_app_t_ {

  /**	Messages array, either localized messages or default texts.
  */
  dkChar const * const	*msg;

  /**	Input file name currently processed (used in error messages).
  */
  dkChar const		*n_sourcefile;

  /**	Command line arguments.
  */
  dkChar const * 	*argv;

  /**	Application name.
  */
  dkChar const		*n_app;

  /**	Name of executable file for process.
  */
  dkChar const		*n_execfile;

  /**	Directory bin (directory for binaries - bindir).
  */
  dkChar const		*n_bindir;

  /**	Directory etc (system configuration directory - sysconfdir).
  */
  dkChar const		*n_etcdir;

  /**	Directory share (data root directory - datarootdir).
  */
  dkChar const		*n_sharedir;

  /**	Directory var (local state directory - vardir).
  */
  dkChar const		*n_vardir;

  /**	Login name of process owner.
  */
  dkChar const		*n_logname;

  /**	Home directory of process owner.
  */
  dkChar const		*n_homedir;

  /**	Aplication group name.
  */
  dkChar const		*n_appgroup;

  /**	File name for log file.
  */
  dkChar const		*n_logfilename;

  /**	Directory for temporary files.
  */
  dkChar const		*n_tmpdir;

  /**	Users language.
  */
  dkChar const		*n_language;

  /**	Users region.
  */
  dkChar const		*n_region;

  /**	Language/region setting string from environment or registry.
  */
  dkChar const		*n_langstr;

  /**	Host name.
  */
  dkChar const		*n_hostname;

  /**	Container for message catalogs.
  */
  dk3_sto_t		*s_mc;

  /**	Iterator through message catalogs container.
  */
  dk3_sto_it_t		*i_mc;

  /**	Container for preferences read from command line.
  */
  dk3_sto_t		*s_cmdprefs;

  /**	Iterator through command line preferences container.
  */
  dk3_sto_it_t		*i_cmdprefs;

  /**	Container for self-set preferences.
  */
  dk3_sto_t		*s_selfprefs;

  /**	Iterator through self-set preferences container.
  */
  dk3_sto_it_t		*i_selfprefs;

  /**	Container for system-wide preferences.
  */
  dk3_sto_t		*s_sysprefs;

  /**	Iterator through system-wide preferences container.
  */
  dk3_sto_it_t		*i_sysprefs;

  /**	Container for users constant preferences.
  */
  dk3_sto_t		*s_constprefs;

  /**	Iterator through users constant preferences container.
  */
  dk3_sto_it_t		*i_constprefs;

  /**	Container for users variable preferences.
  */
  dk3_sto_t		*s_varprefs;

  /**	Iterator through users variable preferences container.
  */
  dk3_sto_it_t		*i_varprefs;

  /**	Timestamp: Last logging to stderr.
  */
  dk3_time_t		 t_last_log_stderr;

  /**	Timestamp: Last logging to file.
  */
  dk3_time_t		 t_last_log_file;

  /**	Line number in current input file (used in error messages).
  */
  unsigned long		sourceline;

  /**	Name part of next temporary file name.
  */
  unsigned long		ul_tmpname;

  /**	Suffix part of next temporary file name.
  */
  unsigned		u_tmpsuffix;

  /**	Application type, see @ref apptypes.
  */
  int	app_type;

  /**	Error code, report delayed after finishing application initialization.
  */
  int	de;

  /**	Log level required for reporting to stderr, see @ref loglevels.
  */
  int	ll_stderr;

  /**	Log level required for reporting to file, see @ref loglevels.
  */
  int	ll_file;

  /**	Log level required to keep log file, see @ref loglevels.
  */
  int	ll_file_keep;

  /**	Log level required to keep temporary files, see @ref loglevels.
  */
  int	ll_tmp_keep;

  /**	Most relevant log level found, see @ref loglevels.
  */
  int	ll_highest;

  /**	Carry flag, too many temporary file names requested.
  */
  int	i_tmpcarry;

  /**	Number of command line arguments.
  */
  int	argc;

  /**	Internal encoding, used for strings in memory, see @ref stringenc.
  */
  int	i_encoding;

  /**	Encoding for output files, see @ref fileenc.
  */
  int	i_output_encoding;

  /**	Encoding expected on stdin, see @ref fileenc.
  */
  int	i_stdin_input_encoding;

  /**	Encoding expected when reading from files, see @ref fileenc.
  */
  int	i_file_input_encoding;

  /**	Flag: Unconfigure application (delete users variable preferences)
	when finishing the application.
  */
  int	f_unconfigure;

  /**	Flag: Changes applied to preferences, need to save when finishing
	the application.
  */
  int	f_prefschanged;

  /**	Flag: Setup completed, we can write log messages.
  */
  int	f_readytolog;

  /**	Flag: First attempt to log to file.
  */
  int	f_first_file_log;

  /**	Flag: Already attempted to initialize PRNG.
  */
  int	f_rand_initialized;

  /**	Flag: PRNG was initialized successfully.
  */
  int	f_rand_success;

  /**	PRNG type to use, see @ref rndtypes.
  */
  int	rand_type;

  /**	Flag: ${HOME}/log created.
  */
  int	cr_log;

  /**	Flag: ${HOME}/tmp/xxx created.
  */
  int	cr_tmp;

} dk3_app_t;



/**	File search result.
*/
typedef struct _dk3_search_t_ {

  /**	Container for all file names found.
  */
  dk3_sto_t	*s_fn;

  /**	Iterator for all file names container.
  */
  dk3_sto_it_t	*i_fn;

  /**	Application structure, used for diagnostics.
  */
  dk3_app_t	*app;

  /**	Number of next file to add.
  */
  unsigned long	nf;

  /**	Flag: Inverted search order (most relevant files first).
  */
  int		inverted;
} dk3_search_t;



/**	Bit field.
*/
typedef struct _dk3_bf_t_ {

  /**	Data bytes to store the bits.
  */
  unsigned char	*data;

  /**	Optional application structure for diagnostics.
  */
  dk3_app_t	*app;

  /**	Number of bits to save.
  */
  size_t	nbits;
} dk3_bf_t;



/**	Bit matrix.
*/
typedef struct _dk3_bm_t_ {

  /**	Data bytes to store the bits.
  */
  unsigned char	**data;

  /**	Optional application structure for diagnostics.
  */
  dk3_app_t	*app;

  /**	Size of available cache for dk3bm_expand.
  */
  size_t	cachesize;

  /**	Number of bits per row.
  */
  size_t	columns;

  /**	Number of rows.
  */
  size_t	rows;
} dk3_bm_t;



/**	LaTeX font encoding information.
*/
typedef unsigned char dk3_font_encoding_t;


/**	Information about one package needed for an encoding.
*/
typedef struct {
  char const	*name;	/**< Package name. */
  char		 used;	/**< Flag: Package used. */
} dk3_uc2lat_pkg_t;


/**	Pointer to a package information.
*/
typedef dk3_uc2lat_pkg_t	*dk3_uc2lat_pkg_ptr;

/**	Pointer to pointer to a package information.
*/
typedef	dk3_uc2lat_pkg_ptr	*dk3_uc2lat_pkg_pptr;


/**	Directory entry for UC to LaTeX, represents one input file.
*/
typedef struct {

  /**	Container to store ranges.
  */
  dk3_sto_t		*s_ran;

  /**	Iterator through ranges container.
  */
  dk3_sto_it_t		*i_ran;

  /**	Short file name containing data for this directory entry.
  */
  dkChar const		*sn;

  /**	Flag: Data was loaded.
  */
  unsigned char		loaded;
} dk3_uc2lat_dir_t;



/**	Range of UC characters.
*/
typedef struct {

  /**	LaTeX encodings for both text and math mode.
  */
  char const		**a;

  /**	LaTeX encodings for text mode only.
  */
  char const		**t;

  /**	LaTeX encodings for math mode only.
  */
  char const		**m;

  /**	Descriptions texts for character.
  */
  dkChar const		**dsc;

  /**	Package collections required for character.
 	NOT USED IN itadmin.
  */
  dk3_uc2lat_pkg_t	***p;

  /**	Information about font encodings required by characters.
  */
  dk3_font_encoding_t	*f;

  /**	Directory entry responsible for this range.
  */
  dk3_uc2lat_dir_t	*dir;

  /**	First character in range.
  */
  dk3_c32_t		start;

  /**	Last character in range.
  */
  dk3_c32_t		end;

  /**	Flag: Initialization of range attempted, no second attempt.
  */
  unsigned char		ia;
} dk3_uc2lat_range_t;



/**	Data for U32 to LaTeX conversion.
*/
typedef struct {

  /**	Application structure for diagnostics and file search.
  */
  dk3_app_t	*app;

  /**	Name of data directory containing the LaTeX encodings.
  */
  dkChar const	*dir;

  /**	Allocated buffer for characters directly passed through.
  */
  char		*buf;

  /**	Container for ranges.
  */
  dk3_sto_t	*s_ran;

  /**	Iterator through ranges container.
  */
  dk3_sto_it_t	*i_ran;

  /**	Container for directories.
  */
  dk3_sto_t	*s_dir;

  /**	Iterator for directories container.
  */
  dk3_sto_it_t	*i_dir;

  /**	Container for packages.
  */
  dk3_sto_t	*s_pkg;

  /**	Iterator through packages container.
  */
  dk3_sto_it_t	*i_pkg;

  /**	Cache: Last range used.
  */
  dk3_uc2lat_range_t	*rca;

  /**	Size of buffer @a buf.
  */
  size_t	 szbuf;

  /**	Flag: Load descriptions for characters too (normally the
	descriptions are ignored).
  */
  int		 f_dsc;

  /**	Flag: Generate UTF-8 output.
  */
  int		 f_utf8;

  /**	Font encoding information.
  */
  dk3_font_encoding_t	fe;
} dk3_uc2lat_t;



/**	Handler function for one line.
	@param	obj	Object to modify using the line.
	@param	il	Input line to process.
	@return	1=OK, 0=error, can continue, -1=error, abort processing.
*/
typedef
int
dk3_line_handler_t(
  void		*obj,
  dkChar	*il
);



/**	Struct for processing a file line by line.
*/
typedef struct {
  /**	Application structure for diagnostics.
  */
  dk3_app_t		*app;
  /**	Data object to modify while processing input lines.
  */
  void			*obj;
  /**	Handler function.
  */
  dk3_line_handler_t	*hf;
  /**	Buffer for input lines.
  */
  dkChar		*buf;
  /**	Current insertion position for next character to add.
  */
  dkChar		*cp;
  /**	Size of input buffer @a buf.
  */
  size_t		 szbuf;
  /**	Number of characters used in @a buf.
  */
  size_t		 bufus;
  /**	System encoding, see @ref stringenc.
  */
  int			 se;
} dk3_line_handler_data_t;



/**	One option.
*/
typedef struct {
  /**	Short option character.
  */
  dkChar 		 so;
  /**	Long option text.
  */
  dkChar const		*lo;
  /**	Flag: Option needs an argument.
  */
  int			 na;
} dk3_option_t;



/**	Options set.
*/
typedef struct {
  /**	Application structure for diagnostics.
  */
  dk3_app_t		 *app;
  /**	Options to find in command line arguments.
  */
  dk3_option_t const	 *options;
  /**	Array of flags, one for each options, whether or not the option was
	found.
  */
  int		 	 *found;
  /**	Array for option arguments.
  */
  dkChar const		**optargs;
  /**	Array of normal arguments (no options and no option arguments).
  */
  dkChar const		**args;
  /**	Further options.
  */
  dkChar const		**fo;
  /**	Short option to introduce further options.
  */
  dkChar		  foc;
  /**	Long option to introduce further options.
  */
  dkChar const		 *focl;
  /**	Number of elements in @a options.
  */
  size_t		  szoptions;
  /**	Number of normal arguments available.
  */
  int			  argsav;
  /**	Number of normal arguments used (found).
  */
  int			  argsused;
  /**	Number of further options available.
  */
  int			  foav;
  /**	Number of further options found.
  */
  int			  fou;
  /**	Error code of last error occured, see @ref errorcodes.
  */
  int			  ec;
} dk3_option_set_t;



/**	Output filter cell details for ASCII/Hex encoding.
*/
typedef struct {
  /**	Number of characters already printed in current line.
  */
  size_t			nl;
} dk3_of_cell_ah_details_t;

/**	Output filter cell details for ASCII85 encoding.
*/
typedef struct {
  /**	32-bit value built up by for bytes.
  */
  unsigned long			val;
  /**	Number of characters merged into @a val.
  */
  size_t			nc;
  /**	Number of characters already printed in current line.
  */
  size_t			nl;
} dk3_of_cell_a85_details_t;



/**	Output filter cell details for run-length compression.
*/
typedef struct {
  /**	Data buffer.
  */
  unsigned char		*bu;
  /**	Number of bytes used in buffer @a bu.
  */
  size_t		 used;
  /**	Number of same bytes repeated.
  */
  size_t		 same;
  /**	Previous character processed.
  */
  unsigned char		 pc;
  /**	Flag: Have a previous character.
  */
  unsigned char		 hc;
  /**	Flag: In a run.
  */
  unsigned char		 run;
} dk3_of_cell_rl_details_t;



#if DK3_HAVE_ZLIB_H
/**	Output filter cell details for flate compression.
*/
typedef struct {
  /**	zlib stream.
  */
  z_stream		*zs;
  /**	Input buffer.
  */
  Bytef			*ibu;
  /**	Output buffer.
  */
  Bytef			*obu;
  /**	Number of input bytes used.
  */
  uLong			 iused;
  /**	Flag: Everything ok, no errors yet.
  */
  int			 ok;
} dk3_of_cell_flate_details_t;
#endif


/**	Output filter cell details.
*/
typedef union {
#if DK3_HAVE_ZLIB_H
    /**	Flate compression data.
    */
    dk3_of_cell_flate_details_t	flate;
#endif
    /**	Run-length compression data.
    */
    dk3_of_cell_rl_details_t	psrl;
    /**	ASCII85 encoding data.
    */
    dk3_of_cell_a85_details_t	a85;
    /**	ASCII-Hex encoding data.
    */
    dk3_of_cell_ah_details_t	ah;
} dk3_of_cell_details_t;



/**	Output filter cell.
*/
typedef struct _dk3_of_cell_t_ {
  /**	Compression/encoding algorithm-specific data.
  */
  dk3_of_cell_details_t		data;
  /**	Next cell downwards.
  */
  struct _dk3_of_cell_t_	*down;
  /**	Next cell upwards.
  */
  struct _dk3_of_cell_t_	*up;
  /**	Output filter owning this cell.
  */
  void				*of;	/**< Output filter. */
  /**	Output filter cell type DK3_OF_CELL_TYPE_xxx,
	see @ref outputfiltercelltypes.
  */
  int				 type;
} dk3_of_cell_t;



/**	Output filter on top of a stream.
*/
typedef struct {
  /**	Application structure for diagnostics.
  */
  dk3_app_t		*app;
  /**	Output stream to receive the filtered data.
  */
  dk3_stream_t		*os;
  /**	Bottom filter cell (next to the stream).
  */
  dk3_of_cell_t		*bottom;
  /**	Top filter cell (input goes to here).
  */
  dk3_of_cell_t		*top;
  /**	Number of cells.
  */
  size_t		 nCells;
  /**	Number of bits used in the @a bits variable.
  */
  size_t		 nBits;
  /**	The bits stored so far.
  */
  unsigned char		 bits;
  /**	Flag set for output filter.
  */
  unsigned char		 flags;
} dk3_of_t;



#if 0

/**	One datum stored in the in-memory database.
*/
typedef struct {
  /**	Start address of data.
  */
  void		*data;
  /**	Data size (number of bytes).
  */
  size_t	 size;
} dk3_memdb_datum_t;



/**	In-memory database.
*/
typedef struct {
  /**	Container for the key/value pairs.
  */
  dk3_sto_t		*st;
  /**	Iterator through key/value pair container.
  */
  dk3_sto_it_t		*it;
  /**	Application structure for diagnostics.
  */
  dk3_app_t		*app;
  /**	File name of database on disk.
  */
  dkChar const		*fn;
  /**	Start of key.
  */
  char			*kb;
  /**	Start of value.
  */
  char			*vb;
  /**	Input line buffer.
  */
  char			*il;
  /**	Binary key size.
  */
  size_t		 szkb;
  /**	Text key size.
  */
  size_t		 szkt;
  /**	Binary value size.
  */
  size_t		 szvb;
  /**	Text value size.
  */
  size_t		 szvt;
  /**	Text line size.
  */
  size_t		 szl;
  /**	Error code of last error occured, see @ref errorcodes.
  */
  int			 ec;
  /**	Flag: Dirty (synchronization needed).
  */
  int			 f_dt;
} dk3_memdb_t;

#endif



/**	Data to store in a database as key or value.
*/
typedef struct {
  /**	Data bytes.
  */
  void		*dt;
  /**	Number of bytes.
  */
  size_t	 sz;
} dk3_datum_t;



/**	Details for a memory database.
*/
typedef struct {
  /**	Container for key/value pairs.
  */
  dk3_sto_t		*s_mem;
  /**	Container iterator.
  */
  dk3_sto_it_t		*i_mem;
} dk3_dbi_mem_details_t;



/**	Details for Berkeley DB database.
*/
typedef struct {
  /**	The BDB database.
  */
  void			*dbptr;
} dk3_dbi_bdb_details_t;



/**	Details for NDBM database.
*/
typedef struct {
  /**	8-bit character file name, only used if dkChar is 16 bit or above.
  */
  void			*dbptr;
} dk3_dbi_ndbm_details_t;



/**	Database type specific details.
*/
typedef union {
  /**	Memory database.
  */
  dk3_dbi_mem_details_t		mem;
  /**	Berkeley database details.
  */
  dk3_dbi_bdb_details_t		bdb;
  /**	NDBM database details.
  */
  dk3_dbi_ndbm_details_t	ndbm;
} dk3_dbi_details_t;



/**	Database interface.
*/
typedef struct {
  /**	Database type specific details.
   */
  dk3_dbi_details_t	details;
  /**	Application structure for diagnostics.
  */
  dk3_app_t		*app;
  /**	File name for database on disk.
  */
  dkChar const		*fn;
  /**	Database type, DK3_DB_TYPE_xxx, see @ref databasetypes.
  */
  int			tp;
  /**	Flag: Database opened for writing.
  */
  int			wr;
  /**	Flag: Database modified, sync to file necessary.
  */
  int			mod;
  /**	Flag: Write error messages for keys not found.
  */
  int			rfk;
  /**	Error code for last error occured.
  */
  int			ec;
} dk3_dbi_t;



/**	BIF coordinates type.
	Must include negative values as predictor operators may
	try to obtain values in row and column -1.
*/
typedef long	dk3_bif_coord_t;



/**	BIF pixel value type.
*/
typedef unsigned short dk3_bif_pixel_t;

/**	Size of BIF pixel value.
*/
#define	DK3_SIZEOF_BIF_PIXEL_T	DK3_SIZEOF_SHORT

/**	Pixel resample information.
*/
typedef struct {
  size_t		iw;	/**< Input width. */
  size_t		ow;	/**< Output width. */
  dk3_bif_pixel_t	im;	/**< Input maximum. */
  dk3_bif_pixel_t	om;	/**< Output maximum. */
  dk3_bif_pixel_t	im2;	/**< Half of input minimum. */
} dk3_pixel_resample_t;



/**	One frame in bitmap image file.
*/
typedef struct {
  /**	X resolution.
  */
  double		 xres;
  /**	Y resolution.
  */
  double		 yres;
  /**	Bitmap type specific data per frame.
  */
  void			*implspec;
  /**	Frame width.
  */
  dk3_bif_coord_t	 w;
  /**	Frame height.
  */
  dk3_bif_coord_t	 h;
  /**	Bits per component for frame found in file.
  */
  size_t		 bits;
  /**	Number of non-redundant bits in @ bits.
  */
  size_t		 realbits;
  /**	Frame number.
  */
  size_t		 n;		/**< Frame number. */
  /**	Color space, DK3_COLOR_SPACE_xxx, see @ref colorspaces.
  */
  int			 cs;
  /**	Flag: Really colored, 1=colored, 0=gray.
  */
  int			 realcolor;
  /**	Flag: Really found alpha data.
  */
  int			 realalpha;
  /**	Flag: Background color defined for frame.
  */
  int			 bg;
  /**	Background red found in file.
  */
  dk3_bif_pixel_t	 bgr;
  /**	Background green found in file.
  */
  dk3_bif_pixel_t	 bgg;
  /**	Background blue found in file.
  */
  dk3_bif_pixel_t	 bgb;
  /**	Background gray found in file.
  */
  dk3_bif_pixel_t	 bggr;
} dk3_bif_frame_t;



/**	Bitmap image file.
*/
typedef struct {
  /**	Structure to upsample or downsample pixel values.
  */
  dk3_pixel_resample_t	 pr;
  /**	Application structure for diagnostics.
  */
  dk3_app_t		*app;
  /**	Container for frames.
  */
  dk3_sto_t		*s_frames;
  /**	Iterator through frames container.
  */
  dk3_sto_it_t		*i_frames;
  /**	Current frame to process.
  */
  dk3_bif_frame_t	*cf;
  /**	Bitmap image type specific data per file.
  */
  void			*implspec;
  /**	Name of temporary file (if any), may be NULL.
  */
  char const		*tmpfn;
  /**	Temporary file (if any), may be NULL.
  */
  FILE			*tmpfipo;
  /**	Number of bitmap image file within process.
  */
  unsigned long		 n;
  /**	Number of frames available.
  */
  size_t		 n_frames;
  /**	Bits per component requested for output.
  */
  size_t		 bits;
  /**	BIF image type DK3_BIF_IMAGE_TYPE_xxx, see @ref bifimagetypes.
  */
  int			 bt;
  /**	Flag: Force use of requested background over bg found in file.
  */
  int			 bg;
  /**	Flag: Remove temporary file when closing the structure.
  */
  int			 remtmpf;
  /**	Background red requested.
  */
  dk3_bif_pixel_t	 bgr;
  /**	Background green requested.
  */
  dk3_bif_pixel_t	 bgg;
  /**	Background blue requested.
  */
  dk3_bif_pixel_t	 bgb;
} dk3_bif_t;



/**	Paper size description. All sizes are specified in PS points.
*/
typedef struct {
  /**	Width.
  */
  double	w;
  /**	Height.
  */
  double	h;
  /**	Left border (inner border for duplex without tumble).
  */
  double	i;
  /**	Right border (outer border for duplex without tumble).
  */
  double	o;
  /**	Top border (inner border for duplex with tumble).
  */
  double	t;
  /**	Bottom bofder (outer border for duplex with tumble).
  */
  double	b;
} dk3_paper_size_t;



/**	Named paper size.
*/
typedef struct {
  /**	Size.
  */
  dk3_paper_size_t		 size;
  /**	Size name.
  */
  dkChar const		*name;
} dk3_named_paper_size_t;



/**	Collection of multiple named paper sizes.
*/
typedef struct {
  /**	Application structure for diagnostics and file search.
  */
  dk3_app_t		*app;
  /**	Container of named paper sizes.
  */
  dk3_sto_t		*s_sizes;
  /**	Iterator through named paper sizes container.
  */
  dk3_sto_it_t		*i_sizes;
} dk3_paper_size_collection_t;






/**	Area to place an image.
*/
typedef struct {
  /**	Left x.
  */
  double	xl;
  /**	Right x.
  */
  double	xr;
  /**	Top y.
  */
  double	yt;
  /**	Bottom y.
  */
  double	yb;
} dk3_image_area_t;



/**	Area to place a PS/PDF image.
*/
typedef union {
  /**	Paper size for creating a document.
  */
  dk3_paper_size_t	ps;
  /**	Image area to use when converting Fig to PS.
  */
  dk3_image_area_t	ia;
} dk3_bm_eps_area_t;



/**	Object start position.
*/
typedef struct {
  /**	Object number.
  */
  unsigned long		objno;

  /**	Start position in file.
  */
  dk3_um_t		startpos;
} dk3_pdf_position_t;



/**	XObject representing one image or alpha mask.
*/
typedef struct {
  /**	Name of temporary file with contents.
  */
  dkChar const		*tempfilename;

  /**	Xobject for alpha mask.
  */
  void			*mask;

  /**	Stream length.
  */
  dk3_um_t		slgt;

  /**	Image width (number of pixels).
  */
  dk3_bif_coord_t	width;

  /**	Image height (number of pixels).
  */
  dk3_bif_coord_t	height;

  /**	Object number for XObject.
  */
  unsigned long		objno;

  /**	XObject type DK3_PDF_XO_TYPE_xxx, see @ref pdfxobjecttype.
  */
  int			xot;

  /**	Procedure for object, DK3_BMEPS_xxx, see @ref bmepscompression.
  */
  int			procedure;

  /**	Bits per component.
  */
  int			bpc;

  /**	Flag: Stream is DCT (1) or flate (0).
  */
  int			dct;

  /**	Predictor DK3_COMPRESSIONPREDICTOR_xxx, see @ref flatepredictors.
  */
  int			pred;

  /**	Flag: Adobe marker was found in CMYK DCT file.
  */
  int			adobe_marker_found;

  /**	Flag: Used by current page.
  */
  int			used;

  /**	Flag: Interpolate this object.
  */
  int			interpolate;
} dk3_pdf_xobject_t;



/**	One PDF page.
*/
typedef struct {
  /**	Name of temporary file for page description stream.
  */
  dkChar const		*tempfilename;

  /**	Temporary file.
  */
  FILE			*tempfile;

  /**	Stream to write to temporary file.
  */
  dk3_stream_t		*tempstream;

  /**	Output filter, used to write to temporary file.
  */
  dk3_of_t		*tempof;

  /**	Collection of all XObjects used by this page.
  */
  dk3_sto_t		*s_xobjects;

  /**	Iterator through XObjects collection.
  */
  dk3_sto_it_t		*i_xobjects;

  /**	Stream length.
  */
  dk3_um_t		slgt;

  /**	PDF object number.
  */
  unsigned long		objno;

  /**	Page number.
  */
  unsigned long		pageno;

  /**	Media box x0.
  */
  long			mbx0;

  /**	Media box x1.
  */
  long			mbx1;

  /**	Media box y0.
  */
  long			mby0;

  /**	Media box y1.
  */
  long			mby1;
} dk3_pdf_page_t;



/**	Structure used to write a PDF file.
*/
typedef struct {
  /**	Application structure, used to find temporary file names.
  */
  dk3_app_t		*app;

  /**	XObject storage (bitmaps).
  */
  dk3_sto_t		*s_xobjects;

  /**	Iterator through XObject storage.
  */
  dk3_sto_it_t		*i_xobjects;

  /**	Pages storage.
  */
  dk3_sto_t		*s_pages;

  /**	Iterator through pages storage.
  */
  dk3_sto_it_t		*i_pages;

  /**	Current page.
  */
  dk3_pdf_page_t	*cp;

  /**	Next XObject object number.
  	First Xobject is object number 4 as we have info object,
	root object and pages collection object as 1, 2, and 3.
  */
  unsigned long		nextobject;

  /**	Next page number.
  */
  unsigned long		nextpage;

  /**	Media box x0 for next page.
  */
  long			mbx0;

  /**	Media box x1 for next page.
  */
  long			mbx1;

  /**	Media box y0 for next page.
  */
  long			mby0;

  /**	Media box y1 for next page.
  */
  long			mby1;

  /**	Flag: Document mode (1) or image/object (0).
  */
  int			documentMode;

} dk3_pdf_t;


/**	Options to convert a bitmap image to PS/PDF.
*/
typedef struct {
  /**	Image area.
  */
  dk3_bm_eps_area_t	ima;

  /**	Resolution in dpi.
  */
  double		resolution;

  /**	Application structure for diagnostics, may be NULL.
  */
  dk3_app_t		*app;

  /**	Output driver DK3_BMEPS_DRIVER_xxx, see @ref bmepsdrivers.
  */
  int			dr;

  /**	Run mode DK3_BMEPS_MODE_xxx, see @ref dkbmmodes.
  */
  int			mode;

  /**	Size conversion mode.
  */
  int			szmode;

  /**	Compression predictor for flate compression,
	DK3_COMPRESSION_PREDICTOR_xxx, see @ref flatepredictors.
  */
  int			pred;

  /**	Image origin position DK3_IMAGE_ORIGIN, see @ref imageorigin.
  */
  int			io;

  /**	Flag: Draft mode.
  */
  int			draft;

  /**	Flag: Printout in duplex.
  */
  int			duplex;

  /**	Flag: Printout in tumble mode (like a calendar).
  */
  int			tumble;

  /**	PS level (2 or 3).
  */
  int			psl;

  /**	Flag: Write DSC comments.
  */
  int			dsc;

  /**	Flag: Allow direct DCT data transfer.
  */
  int			dct;

  /**	Flag: Keep aspect ratio.
  */
  int			kar;

  /**	Requested/suggested background red, 8 bits per pixel.
  */
  int			bgr;

  /**	Requested/suggested background green, 8 bits per pixel.
  */
  int			bgg;

  /**	Requested/suggested background blue, 8 bits per pixel.
  */
  int			bgb;

  /**	Flag: Enforce this background over bg color found in file.
  */
  int			fbg;

  /**	Flag: Image interpolation enabled.
  */
  int			ip;

  /**	Flag: Image interpolation enabled for JPEG files too.
  */
  int			jip;

  /**	Flag: Make mode.
  */
  int			make;

  /**	Write colored output.
  */
  int			color;

  /**	Flag: Reduce bits per component.
  */
  int			rbpc;

  /**	Flag: Write to stdout.
  */
  int			to_stdout;
} dk3_bm_eps_options_t;



/**	Internal conversion job structure.
*/
typedef struct {

  /**	Conversion option set.
  */
  dk3_bm_eps_options_t		*opt;

  /**	Localized message texts.
  */
  dkChar const * const		*msg;

  /**	Source file name.
  */
  dkChar const			*sfn;

  /**	Destination file name.
  */
  dkChar const			*dfn;

  /**	Destination file.
  */
  FILE				*dfile;

  /**	PDF writer structure.
  */
  dk3_pdf_t			*pdf;

  /**	Bitmap image file.
  */
  dk3_bif_t			*bif;

  /**	Communication object.
  */
  void				*pComm;

  /**	Translation x.
  */
  double			 x_translate;

  /**	Translation y.
  */
  double			 y_translate;

  /**	Scale x.
  */
  double			 x_scale;

  /**	Scale y.
  */
  double			 y_scale;

  /**	Left x coordinate (used for the draft).
  */
  double			 x_0;

  /**	Right x coordinate (used for the draft).
  */
  double			 x_1;

  /**	Lower y coordinate (used for the draft).
  */
  double			 y_0;

  /**	Upper y coordinate (used for the draft).
  */
  double			 y_1;

  /**	Image width (bounding box).
  */
  long				 x_size;

  /**	Image width (bounding box).
  */
  long				 y_size;

  /**	Number of bits per component.
  */
  size_t			 bpc;

  /**	Number of pages to produce.
  */
  size_t			 nPages;

  /**	Number of current page.
  */
  size_t			 currentPage;

  /**	Minimum value for progress bar.
  */
  int				 minpb;

  /**	Maximum value for progress bar.
  */
  int				 maxpb;

  /**	Image file type.
  */
  int				 biftype;

  /**	Flag: Must translate coordinates.
  */
  int				 do_translate;

  /**	Rotation (multiples of 90 degree).
  */
  int				 do_rotate;

  /**	Use floating point numbers for scaling.
  */
  int				 do_float_scale;

  /**	Flag: Must do header and footer.
  */
  int				 do_header_footer;

  /**	Output procedure DK3_BMEPS_xxx, see @ref bmepscompression.
  */
  int				 procedure;

} dk3_bm_conversion_job_t;



/**	Information about one font.
*/
typedef struct {
  char const		*psFontName;	/**< PS font name. */
  char const		*texFontName;	/**< LaTeX font name. */
  char const		*texFamilyName;	/**< LaTeX font family name. */
  char const		*gsFontName;	/**< GhostScript font name. */
  char const		*gsFileOld;	/**< Old GhostScript font file name. */
  char const		*gsFileNew;	/**< New GhostScript font file name. */
  char const		*psFamilyName;	/**< PS font family name. */
  char const		*svgFamilyName;	/**< SVG font family name. */
  char const		*svgFontId;	/**< SVG font identifier. */
  char const * const	*replacements;	/**< Replacement family names. */
  int			 features;	/**< Font features (bold/italic). */
  int			 svgFeatures;	/**< Font features when used in SVG. */
  int			 svgFontWeight;	/**< Font weight. */
} dk3_font_t;



/**	Bounding box data.
*/
typedef struct {
  double	xmin;	/**< Minimum x. */
  double	xmax;	/**< Maximum x. */
  double	ymin;	/**< Minimum y. */
  double	ymax;	/**< Maximum y. */
  int		xused;	/**< Flag: x-value specified. */
  int		yused;	/**< Flag: y-value specified. */
} dk3_bb_t;



/**	Coordinates transformation-
*/
typedef struct {
  double	mx;	/**< X factor. */
  double	nx;	/**< X summand. */
  double	my;	/**< Y factor. */
  double	ny;	/**< Y summand. */
} dk3_ct_2d_t;



/**	Color specified as RGB.
*/
typedef struct {
  double	r;	/**< Red. */
  double	g;	/**< Green. */
  double	b;	/**< Blue. */
} dk3_rgb_color_t;



/**	Coordinates system transformation to place an image.
	Order of operations is translate, rotate, scale.
*/
typedef struct {
  double	x_translate;	/**< X translation. */
  double	y_translate;	/**< Y translation. */
  double	x_scale;	/**< X scale factor. */
  double	y_scale;	/**< Y scale factor. */
  int		rot;		/**< Rotation angle, multiple of 90 degrees. */
} dk3_coordinates_transformation_t;



/**	Details for a Windows printer.
*/
typedef struct {
  int			dummy;		/**< No details for Windows. */
} dk3_printer_windows_details_t;



/**	Details for LPRng/LPD queue.
*/
typedef struct {
  dkChar const		*hostname;	/**< Destination host name. */
  dkChar const		*queuename;	/**< Destination queue name. */
  double		 to_c;		/**< Timeout for connect. */
  double		 to_r;		/**< Timeout for receive. */
  double		 to_s;		/**< Timeout for send. */
} dk3_printer_lprng_details_t;



/**	Details for a socket connected printer.
*/
typedef struct {
  dkChar const		*hostname;	/**< Destination host or address. */
  unsigned short	 portno;	/**< Port no, host representation. */
  unsigned char		 ordrel;	/**< Flag: Orderly release. */
  double		 to_c;		/**< Timeout for connect. */
  double		 to_r;		/**< Timeout for receive. */
  double		 to_s;		/**< Timeout for send. */
} dk3_printer_socket_t;



/**	Details for a printer.
*/
typedef union {
  dk3_printer_windows_details_t		win;	/**< Windows printer details. */
  dk3_printer_lprng_details_t		lprng;	/**< LPRng printer details. */
  dk3_printer_socket_t			sock;	/**< Socket printer details. */
} dk3_printer_details_t;



/**	Printer.
	Windows printer ports can be a connection to a remote
	raw socket or LPD/LPRng queue. In these cases t_p and det_p
	indicate "Windows printer" and the t_s and det_s contain
	information about the backend.
	For the "clean" and "status" commands we need to access
	the backend, other operations only access the Windows printer.

*/
typedef struct {
  dk3_printer_details_t	 det_p;	/**< Primary type printer details. */
  dk3_printer_details_t	 det_s;	/**< Secondary type printer details. */
  dkChar const		*name;	/**< Printer name. */
  dkChar const		*h_snmp;	/**< Host to access for SNMP. */
  dkChar const		*c_snmp;	/**< SNMP community. */
  int			 t_p;	/**< Primary type,see @ref printertypes.  */
  int			 t_s;	/**< Secondard type, see @ref printertypes.  */
  int			 v_snmp;	/**< SNMP version. */
  int			 ps;	/**< Flag: PS printer. */
} dk3_printer_t;



/**	Queue name alias.
*/
typedef struct {
  dkChar const		*name;		/**< Alias name. */
  dk3_printer_t		*printer;	/**< Alias destination. */
} dk3_printer_alias_t;



/**	Print host.
*/
typedef struct {
  dkChar const		*name;		/**< Host name. */
  double		 to_c;		/**< Timeout for connect. */
  double		 to_r;		/**< Timeout for receive. */
  double		 to_s;		/**< Timeout for send. */
  int			 enc;		/**< Host encoding (plain or UTF-8). */
} dk3_print_host_t;



/**	Print host alias.
*/
typedef struct {
  dkChar const		*name;		/**< Alias name. */
  dk3_print_host_t	*host;		/**< Destination host. */
} dk3_print_host_alias_t;



/**	Print configuration for a computer system.
*/
typedef struct {
  dk3_app_t		*app;		/**< Application structure. */
  dkChar const * const	*msg;		/**< Localized message texts. */
  dk3_sto_t		*sPrinters;	/**< Printers storage. */
  dk3_sto_it_t		*iPrinters;	/**< Iterator through printers. */
  dk3_sto_t		*sPrintAliases;	/**< Printer aliases storage. */
  dk3_sto_it_t		*iPrintAliases;	/**< Iterator through print aliases. */
  dk3_sto_t		*sPrintHosts;	/**< Print hosts storage. */
  dk3_sto_it_t		*iPrintHosts;	/**< Iterator through hosts. */
  dk3_sto_t		*sHostAliases;	/**< Print host aliases storage. */
  dk3_sto_it_t		*iHostAliases;	/**< Iterator through host aliases. */
  dk3_printer_t		*defPrinter;	/**< Default printer. */
  dk3_print_host_t	*defHost;	/**< Default host. */
  int			 defPsl;	/**< Default PS level. */
} dk3_print_conf_t;



#if DK3_HAVE_VOLATILE
/**	The volatile keyword can be used.
*/
#define	DK3_VOLATILE	volatile
#else
/**	The volatile keyword can not be used.
*/
#define	DK3_VOLATILE	/* NIX */
#endif

typedef
#if DK3_HAVE_SIG_ATOMIC_T
/**	Atomic type for signal handlers.
*/
sig_atomic_t
#else
/**	Atomic type or int for signal handlers.
*/
int
#endif
dk3_sig_atomic_t;

/**	Pointer to dkChar.
*/
typedef dkChar		*DK3_PDKCHAR;

/**	Pointer to const dkChar.
*/
typedef	dkChar const	*DK3_PCDKCHAR;

/**	Pointer to unsigned char.
*/
typedef	unsigned char	*DK3_PUCHAR;

/**	Pointer to char.
*/
typedef char		*DK3_PCHAR;

/**	Pointer to char const.
*/
typedef char const	*DK3_PCCHAR;

/**	Return type for signal handlers.
*/
typedef	void		dk3_signal_ret_t;

/**	Signal handler function prototype.
*/
typedef
dk3_signal_ret_t
dk3_signal_fct_t(int)
/*^modifies internalState^*/
;

/**	Signal disposition (handler function address).
*/
typedef	dk3_signal_fct_t	*dk3_signal_disp_t;

/**	Handler function for one character.
	@param	obj	Object to modify using the line.
	@param	ch	Character to process.
	@return	1=OK, 0=error, can continue, -1=error, abort processing.
*/
typedef
int
dk3_char_handler_t(
  void		*obj,
  dk3_c32_t	 ch
);

/**	Function to traverse a simple database.
	@param	obj	Object to modify while traversing the database.
	@param	key	Key data.
	@param	val	Value data.
	@return	1 on success, 0 on error (can continue), -1 on error (abort).
*/
typedef
int
dk3_db_traverse_fct_t(
  void		*obj,
  dk3_datum_t	*key,
  dk3_datum_t	*val
)
/*^modifies *obj,*key,*val^*/
;

/**	Position in a text stream.
*/
typedef struct {
  dk3_um_t	bytes;	/**< Number of bytes successfully proceeded. */
  dk3_um_t	chars;	/**< Number of current character. */
  dk3_um_t	lineno;	/**< Current line number. */
  dk3_um_t	charil;	/**< Current character position in line. */
} dk3_text_stream_position_t;

#endif