summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/ATTRIB/ATTRIB.C
blob: b12a470beea570ec2fa70df137fe9b50b061cfae (plain) (blame)
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
/* 0 */
/*���������������������������������������������������������������������������*/
/*                                                                           */
/*    Utility Name:     ATTRIB.EXE                                           */
/*                                                                           */
/*    Source File Name: ATTRIB.C                                             */
/*                                                                           */
/*    Utility Function:                                                      */
/*                                                                           */
/*       Allows you to set or reset the Archive bit, the Read-Only bit and   */
/*       the Extended Attributes.  Also allows you to display the current    */
/*       setting of those attributes.                                        */
/*                                                                           */
/*    Status:           ATTRIB Utility, DOS Version 4.0                      */
/*                                                                           */
/*    Entry Point: inmain(line)                                              */
/*                                                                           */
/*    Input:       line = DOS command line parameters                        */
/*                                                                           */
/*    Exit-normal: attribute set, or attribute printed to output device      */
/*                                                                           */
/*    Exit-error:  error message written to standard error device            */
/*                                                                           */
/*    Internal References:                                                   */
/*                                                                           */
/*      Routines:                                                            */
/*                                                                           */
/*    External References:                                                   */
/*                                                                           */
/*       Routines:                                                           */
/*              parse()          module=_parse.sal                           */
/*              sysloadmsg()     module=_msgret.sal                          */
/*              sysdispmsg()     module=_msgret.sal                          */
/*              getpspbyte()     module=new_c.sal                            */
/*              putpspbyte()     module=new_c.sal                            */
/*              segread()        module=dos.h(C library)                     */
/*              intdosx()        module=dos.h(C library)                     */
/*              intdos()         module=dos.h(C library)                     */
/*                                                                           */
/*    Notes:                                                                 */
/*    Syntax (Command Line)                                                  */
/*                                                                           */
/*  ATTRIB [+R|-R] [+A|-A] [d:][path]filename[.ext] [[id]|[id=value]] [/S]   */
/*                                                                           */
/*            where:                                                         */
/*                                                                           */
/*                 +R = Make file ReadOnly by setting READONLY bit           */
/*                 -R = Reset READONLY bit                                   */
/*                 +A = Set ARCHIVE bit                                      */
/*                 -A = Reset ARCHIVE bit                                    */
/*                                                                           */
/*                 id = Set or display the extended attribute named by id.   */
/*                      Only one id processed per invocation. id can be *.   */
/*                                                                           */
/*                 /S = Process subdirectories also                          */
/*                                                                           */
/*    Copyright 1988 Microsoft Corporation				     */
/*                                                                           */
/*    Revision History:                                                      */
/*                                                                           */
/*               Modified 6/22/87   v. 4.0			             */
/*               Rewritten 9/28/87   v. 4.0 		      - AN000	     */
/*                        - fixed check for "." & ".."        - AN001        */
/*               PTM 3195 - changed Extended attribute MSGs   - AN002        */
/*               PTM 3588 - Do C exit not DOS exit.           - AN003        */
/*               PTM 3783 - Fix for hang problem.             - AN004        */
/*                                                                           */
/*   NOTE:                                                                   */
/*     When extended attributes are added back in, make sure you change the  */
/*     attrib.skl file back to the original DOS 4.0 ext. attr. error msgs.   */
/*                                                                           */
/*     Also, this C program requires a special lib when linking to take care */
/*     of the fact that the c lib saves the DOS environment on the heap and  */
/*     if the environment is > 32k, STACK OVERFLOW will occur.               */
/*���������������������������������������������������������������������������*/

#include <stdio.h>                                                     /*;AN000;*/
#include <io.h>                                                        /*;AN000;*/
#include <dos.h>                                                       /*;AN000;*/
#include <string.h>                                                    /*;AN000;*/
#include "parse.h"                                                     /*;AN000;*/
#include "msgret.h"                                                    /*;AN000;*/
#include "attrib.h"                                                    /*;AN000;*/

/*���������������������������������������������������������������������������*/
/* Beginning of code (variables declared in attrib.h)                        */
/*���������������������������������������������������������������������������*/

/*
 * inmain() - This routine receives control from an assembler routine and from
 *            here, main is called. This routine first parses the command line
 *            and then does the appropriate action.
 */
inmain(line)                                                           /*;AN000;*/
   char *line;                                                         /*;AN000;*/
{                                                                      /*;AN000;*/
   main(line);                                                         /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     main()                                           */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Parse the command line, makes a full path-filename, does the       */
/*        appropriate function                                               */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

main(line)                                                             /*;AN000;*/
   char *line;                                                         /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/

   WORD Parse_it();         /* forward declaration */                  /*;AN000;*/
   WORD Make_fspec();       /*   "         "       */                  /*;AN000;*/
   WORD Do_dir();           /*   "         "       */                  /*;AN000;*/
   void Error_exit();       /*   "         "       */                  /*;AN000;*/
   void Parse_err();        /*   "         "       */                  /*;AN000;*/

   /* initialize control variables */
   status = NOERROR;                                                   /*;AN000;*/
   descending = FALSE;                                                 /*;AN000;*/
   set_reg_attr = FALSE;                                               /*;AN000;*/
   pmask = mmask = 0x0;                                                /*;AN000;*/
   ext_attr[0] = BLANK;                                                /*;AN000;*/
   file[0] = '\0';                                                     /*;AN000;*/
   error_file_name[0] = '\0';                                          /*;AN000;*/

   /* load messages */
   sysloadmsg(&inregs,&outregs);                                       /*;AN000;*/
   if (outregs.x.cflag & CARRY) {                                      /*;AN000;*/
      sysdispmsg(&outregs,&outregs);                                   /*;AN000;*/
      Dexit(11);                                                       /*;AN000;*/
      }

   Check_appendx();        /* check APPEND /X status */                /*;AN000;*/
   Get_DBCS_vector();      /* get double byte table */                 /*;AN000;*/

   /* parse command line */
   status = Parse_it(line);                                            /*;AN000;*/
   if (status != NOERROR) {                                            /*;AN000;*/
      Parse_err(status);                                               /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Do extended attribute translations here */
   Ext_translation();                                                  /*;AN000;*/


   /* Initialize any variables need for next phase of program */
   segread(&segregs);     /* init segment registers for DOS calls */   /*;AN000;*/

   /* make full filespec (drive + full path + filename) */
   strcpy(error_file_name,fspec);                                      /*;AN000;*/
   status = Make_fspec(fspec);                                         /*;AN000;*/
   if (status == NOERROR) {                                            /*;AN000;*/

      /* now do the work! */
      did_attrib_ok = FALSE;  /* needed if file not found and no */    /*;AN000;*/
                              /* error detected in Attrib().     */
      status = Do_dir(fspec,file);                                     /*;AN000;*/
      if (status == NOERROR && did_attrib_ok == FALSE)                 /*;AN000;*/
         status = FILENOTFOUND;                                        /*;AN000;*/
      }                                                                /*;AN000;*/

   /* determine if there was an error after attempt to do attrib function */
   /* NOTE: for ext. attr. calls, add 200 to the return code to get the   */
   /* ----  error code for this switch.                                   */
   switch(status) { /* Extended error codes */                         /*;AN000;*/
      case 0:                                                          /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 2:       /* File not found */                               /*;AN000;*/
             Error_exit(ERR_EXTENDED,2,ONEPARM);                       /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 3:       /* Path not found */                               /*;AN000;*/
             Error_exit(ERR_EXTENDED,3,ONEPARM);                       /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 5:       /* Access Denied */                                /*;AN000;*/
             Error_exit(ERR_EXTENDED,5,ONEPARM);                       /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 15:      /* Invalid drive specification */                  /*;AN000;*/
             Error_exit(ERR_EXTENDED,15,ONEPARM);                      /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 199:     /* EA error: undetermined cause */                 /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(199,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 201:     /* EA error: name not found */                     /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(201,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 202:     /* EA error: no space to hold name or value */     /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(202,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 203:     /* EA error: name can't be set on this function */ /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(204,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 204:     /* EA error: name can't be set */                  /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(204,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 205:     /* EA error: name known to this FS but not supported */ /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(205,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 206:     /* EA error: EA definition bad (type, length, etc.) */ /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(206,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      case 208:     /* EA error: EA value not supported */             /*;AN000;*/
             strcpy(error_file_name,ext_attr);                         /*;AN000;*/
             Error_exit(ERR_EXTENDED,87,ONEPARM);                      /*;AN000;*/
             /* Display_msg(208,STDERR,NOSUBPTR,NOSUBCNT,NOINPUT);        /*;AN000;*/
             break;                                                    /*;AN000;*/
      default:      /* Access Denied */                                /*;AN000;*/
             Error_exit(ERR_EXTENDED,5,ONEPARM);                       /*;AN000;*/
             break;                                                    /*;AN000;*/
      }                                                                /*;AN000;*/
   Reset_appendx();                                                    /*;AN000;*/



}  /* end of inmain */                                                 /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*    Subroutine Name: Display_msg                                           */
/*                                                                           */
/*    Subroutine Function:                                                   */
/*       Display the requested message to a given output device              */
/*                                                                           */
/*    Input:                                                                 */
/*        (1) Number of the message to be displayed (see ATTRIB.SKL)         */
/*        (2) Output device handle                                           */
/*        (3) Number of substitution parameters (%1,%2)                      */
/*        (4) Offset of sublist control block                                */
/*        (5) Message Class, 0=no input, 1=input via INT 21 AH=1             */
/*                                                                           */
/*    Output:                                                                */
/*        The message is written to the given output device.  If input       */
/*        was requested, the character code of the key pressed is returned   */
/*        in outregs.x.ax.                                                   */
/*                                                                           */
/*    Normal exit: Message written to handle                                 */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              Sysdispmsg (module _msgret.sal)                              */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Display_msg(msgnum,msghan,msgparms,msgsub,msginput)                    /*;AN000;*/
   int   msgnum;                                                       /*;AN000;*/
   int   msghan;                                                       /*;AN000;*/
   int   msgparms;                                                     /*;AN000;*/
   int   *msgsub;                                                      /*;AN000;*/
   char  msginput;                                                     /*;AN000;*/
{
   inregs.x.ax = msgnum;                                               /*;AN000;*/
   inregs.x.bx = msghan;                                               /*;AN000;*/
   inregs.x.cx = msgparms;                                             /*;AN000;*/
   inregs.h.dh = utility_msg_class;                                    /*;AN000;*/
   inregs.h.dl = msginput;                                             /*;AN000;*/
   inregs.x.si = (WORD)msgsub;                                         /*;AN000;*/
   sysdispmsg(&inregs,&outregs);                                       /*;AN000;*/

   /* check for error printing message */
   if (outregs.x.cflag & CARRY) {                                      /*;AN000;*/
      outregs.x.bx = (WORD) STDERR;                                    /*;AN000;*/
      outregs.x.si = NOSUBPTR;                                         /*;AN000;*/
      outregs.x.cx = NOSUBCNT;                                         /*;AN000;*/
      outregs.h.dl = exterr_msg_class;                                 /*;AN000;*/
      sysdispmsg(&outregs,&outregs);                                   /*;AN000;*/
      }                                                                /*;AN000;*/
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Ext_translation()                                */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        This routine does all translation of extended attribute names to   */
/*        the form that will be returned by Get_ext_attr_names(). For        */
/*        example, "CODEPAGE" would be translated to "CP".                   */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Ext_translation()                                                      /*;AN000;*/
{                                                                      /*;AN000;*/
   if (strcmp(ext_attr,"CODEPAGE") == 0) {                             /*;AN000;*/
      strcpy(ext_attr,"CP");                                           /*;AN000;*/
      }                                                                /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Get_far_str()                                    */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        copies a filename from source to the target. The source is offset  */
/*        from the code segment instead of the data segment.                 */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Get_far_str(target,source,length)                                      /*;AN000;*/
   char *target;                                                       /*;AN000;*/
   DWORD *source;               /* segment = cs register */            /*;AN000;*/
   WORD  length;                                                       /*;AN000;*/
{                                                                      /*;AN000;*/
   char far *fptr;                                                     /*;AN000;*/
   WORD i;                                                             /*;AN000;*/

   if (length == 0) {                                                  /*;AN000;*/

      /* copy string in data segment */
      for (fptr = (char far *) *((DWORD *)source);(char)*fptr != NUL;) /*;AN000;*/
         *target++ = (char) *fptr++;                                   /*;AN000;*/
      *target = *fptr;  /*EOS character */                             /*;AN000;*/
      }                                                                /*;AN000;*/
   else {

      /* copy string in data segment */
      for (fptr = (char far *) *((DWORD *)source),i=0;i < length;i++)  /*;AN000;*/
         *target++ = (char) *fptr++;                                   /*;AN000;*/
      *target = 0x0;    /*EOS character */                             /*;AN000;*/
      }
   strcpy(fix_es_reg,NUL); /* fix for es reg. after using far ptr */   /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Dexit()                                          */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Does a DOS terminate.                                              */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Dexit(s)                                                               /*;AN000;*/
   WORD  s;                                                            /*;AN000;*/
{                                                                      /*;AN000;*/
   Reset_appendx();             /* Reset APPEND /X status */           /*;AN000;*/

/* inregs.h.ah = (BYTE)0x4c;                                           /*;AN003; ;AN000;*/
/* inregs.h.al = (BYTE)s;                                              /*;AN003; ;AN000;*/
/* intdos(&inregs,&outregs);        /*terminate*/                      /*;AN003; ;AN000;*/

   /* if it didn't work - kill it */
   exit();                                                             /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Dallocate()                                      */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Does a DOS allocate of length (in paragraphs).                     */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD *Dallocate(s)                                                     /*;AN000;*/
   WORD s;       /* length in bytes */                                 /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD length;  /*length in paragraphs */                             /*;AN000;*/

   length = (s / 16 + 1);                                              /*;AN000;*/
   inregs.x.bx = length;                                               /*;AN000;*/
   inregs.x.ax = 0x4800;                                               /*;AN000;*/
   intdos(&inregs,&outregs);                                           /*;AN000;*/
   if (outregs.x.cflag & CARRY) {                                      /*;AN000;*/
      Error_exit(ERR_EXTENDED,8,NOSUBCNT);                             /*;AN000;*/
      }                                                                /*;AN000;*/
   return((WORD *)outregs.x.ax);                                       /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Dfree()                                          */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Does a DOS de-allocate.                                            */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Dfree(segment)                                                         /*;AN000;*/
   WORD segment;                                                       /*;AN000;*/
{                                                                      /*;AN000;*/
   segregs.es = segment;                                               /*;AN000;*/
   inregs.x.ax = 0x4900;                                               /*;AN000;*/
   intdosx(&inregs,&outregs,&segregs);                                 /*;AN000;*/
   if (outregs.x.cflag & CARRY) {                                      /*;AN000;*/
      Error_exit(ERR_EXTENDED,8,NOSUBCNT);                             /*;AN000;*/
      }                                                                /*;AN000;*/
   strcpy(fix_es_reg,NUL); /* fix for es reg. after using far ptr */   /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Copy_far_ptr()                                   */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Copies a far ptr declared in any form to a real far ptr variable.  */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: status = NOERROR                                          */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Copy_far_ptr(p1_addr, p2_addr)                                         /*;AN000;*/
   DWORD *p1_addr;                                                     /*;AN000;*/
   WORD  *p2_addr;                                                     /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD  *dptr, *tptr;                                                 /*;AN000;*/

   dptr = (WORD *)p2_addr;                                             /*;AN000;*/
   tptr = (WORD *)p1_addr;                                             /*;AN000;*/

   *tptr++ = *dptr++;                                                  /*;AN000;*/
   *tptr = *dptr;                                                      /*;AN000;*/
   strcpy(fix_es_reg,NUL);       /* fix ES register */                 /*;AN000;*/
}                                                                      /*;AN000;*/

/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Parse_it()                                       */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Parses the command line and returns error status.                  */
/*                                                                           */
/*    Input:  line                                                           */
/*                                                                           */
/*    Output: various control variables are set                              */
/*                                                                           */
/*    Normal exit: status = NOERROR                                          */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Parse_it(line)                                                    /*;AN000;*/
   char *line;                                                         /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD  i;                                                            /*;AN000;*/
   WORD  status;                                                       /*;AN000;*/
   WORD  no_value;                                                     /*;AN000;*/
   WORD  got_fn;         /* got filename - required parameter */       /*;AN000;*/
   WORD  pa,                                                           /*;AN000;*/
         ma,                                                           /*;AN000;*/
         pr,                                                           /*;AN000;*/
         mr;                                                           /*;AN000;*/
   char far *cptr;                                                     /*;AN000;*/
   char *ptr;                                                          /*;AN000;*/
   BYTE  p_mask[4],                                                    /*;AN000;*/
         m_mask[4];                                                    /*;AN000;*/
   char  string[129];                                                  /*;AN000;*/

   /* do setup for parser */
   for (i=0; i<4; i++) {                                               /*;AN000;*/
      p_mask[i] = m_mask[i] = 0;                                       /*;AN000;*/
      }                                                                /*;AN000;*/
   do_reg_attr = TRUE;                                                 /*;AN000;*/
   do_ext_attr = FALSE;                                                /*;AN000;*/
   set_reg_attr = FALSE;                                               /*;AN000;*/
   set_ext_attr = FALSE;                                               /*;AN000;*/
   no_value = TRUE;            /* no value found for keyword */        /*;AN000;*/
   got_fn = FALSE;             /* no filename yet */                   /*;AN000;*/

   inregs.x.si = (WORD)line;      /* Make DS:SI point to source */     /*;AN000;*/
   inregs.x.cx = 0;               /* Operand ordinal */                /*;AN000;*/
   inregs.x.di = (WORD)&p_p1;     /* Address of parm list */           /*;AN000;*/
   status = p_no_error;           /* Init no error condition */        /*;AN000;*/

   /* loop until error or end_of_line */
   while (status == p_no_error) {                                      /*;AN000;*/
      parse(&inregs,&outregs);                                         /*;AN000;*/
      status = outregs.x.ax;       /* get error status */              /*;AN000;*/

      /* check for errors, continue if none */
      if (status == p_no_error) {                                      /*;AN000;*/

         /* check if first positional */
         if (outregs.x.dx == (WORD)&pos1_buff) {                       /*;AN000;*/
            if (*(char *)pos1_buff.p_result_buff[0] == '+')  {         /*;AN000;*/
               p_mask[0] |= pos1_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            else {                                                     /*;AN000;*/
               m_mask[0] |= pos1_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            set_reg_attr = TRUE;                                       /*;AN000;*/
            do_reg_attr = FALSE;                                       /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check if second positional */
         if (outregs.x.dx == (WORD)&pos2_buff) {                       /*;AN000;*/
            if (*(char *)pos2_buff.p_result_buff[0] == '+') {          /*;AN000;*/
               p_mask[1] |= pos2_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            else {                                                     /*;AN000;*/
               m_mask[1] |= pos2_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            set_reg_attr = TRUE;                                       /*;AN000;*/
            do_reg_attr = FALSE;                                       /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check if third positional */
         if (outregs.x.dx == (WORD)&pos3_buff) {                       /*;AN000;*/

            /* copy filename from far string to data segment string */
            Get_far_str(fspec,pos3_buff.p_result_buff,0);              /*;AN000;*/
            got_fn = TRUE;                                             /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check if fourth positional */
         if (outregs.x.dx == (WORD)&pos4_buff) {                       /*;AN000;*/
            if (*(char *)pos4_buff.p_result_buff[0] == '+')  {         /*;AN000;*/
               p_mask[2] |= pos4_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            else {                                                     /*;AN000;*/
               m_mask[2] |= pos4_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            set_reg_attr = TRUE;                                       /*;AN000;*/
            do_reg_attr = FALSE;                                       /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check if fifth positional */
         if (outregs.x.dx == (WORD)&pos5_buff) {                       /*;AN000;*/
            if (*(char *)pos5_buff.p_result_buff[0] == '+') {          /*;AN000;*/
               p_mask[3] |= pos5_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            else {                                                     /*;AN000;*/
               m_mask[3] |= pos5_buff.p_item_tag;                      /*;AN000;*/
               }                                                       /*;AN000;*/
            set_reg_attr = TRUE;                                       /*;AN000;*/
            do_reg_attr = FALSE;                                       /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check if sixth positional */
         if (outregs.x.dx == (WORD)&pos6_buff) {                       /*;AN000;*/

            /* copy attribute name from far string to data segment string */
            Get_far_str(ext_attr,pos6_buff.p_result_buff,0);           /*;AN000;*/
            do_ext_attr = TRUE;                                        /*;AN000;*/
            do_reg_attr = FALSE;                                       /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check if value of sixth positional */
         if (outregs.x.dx == (WORD)&pos6b_buff) {                      /*;AN000;*/

            /* parse a value that is complex (in parenthesis). */
            if (pos6b_buff.p_type == p_complex) {                      /*;AN000;*/

               /* Parse the complex and concatenate it together */
               inregs.x.cx = 0;       /* reset ordinal count */        /*;AN000;*/
               status = p_no_error;                                    /*;AN000;*/
               while (status != p_rc_eol) {                            /*;AN000;*/
                  parse(&inregs,&outregs);                             /*;AN000;*/
                  status = outregs.x.ax;       /* get error status */  /*;AN000;*/
                  if (status != p_no_error) {                          /*;AN000;*/
                     status = p_syntax;                                /*;AN000;*/
                     break;                                            /*;AN000;*/
                     }                                                 /*;AN000;*/
                  Get_far_str(string,pos6b_buff.p_result_buff,0);      /*;AN000;*/
                  strcat(ext_attr_value.ea_ascii,string);              /*;AN000;*/
                  inregs.x.si = outregs.x.si; /* update SI for parser */ /*;AN000;*/
                  }                                                    /*;AN000;*/
               status = p_no_error;                                    /*;AN000;*/
               ext_attr_value_type = EAISASCII;                        /*;AN000;*/
               }                                                       /*;AN000;*/
            else                                                       /*;AN000;*/
               Determine_type((WORD)pos6b_buff.p_type,pos6b_buff.p_result_buff); /*;AN000;*/
            set_ext_attr = TRUE;                                       /*;AN000;*/
            do_reg_attr = FALSE;                                       /*;AN000;*/
            do_ext_attr = FALSE;                                       /*;AN000;*/
            no_value = TRUE;      /* found a value for keyword */      /*;AN000;*/
            }                                                          /*;AN000;*/

         /* check for '/S' switch */
         if (outregs.x.dx == (WORD)&sw_buff) {                         /*;AN000;*/

            /* check if duplicate switch */
            if (descending == TRUE) {                                  /*;AN000;*/
                status = p_syntax;                                     /*;AN000;*/
                }                                                      /*;AN000;*/
            descending = TRUE;                                         /*;AN000;*/
            }                                                          /*;AN000;*/
         }     /* if no error */                                       /*;AN000;*/

      /* error, check if this is first positional, if so try again */
      /* using the second positional beacause they are optional    */
      else if (inregs.x.cx == 0 || inregs.x.cx == 1 ||                 /*;AN000;*/
               inregs.x.cx == 3 || inregs.x.cx == 4) {                 /*;AN000;*/
         inregs.x.cx++;    /* try next positional */                   /*;AN000;*/

         /* Check for a filename beginning with '+' because parser will drop */
         /* the plus sign anyways, and we need to flag it as an error        */
         for(ptr=(char *)inregs.x.si; *ptr == ' '; ptr++)              /*;AN000;*/
            /* NULL statement */ ;                                     /*;AN000;*/
         if (*ptr == '+')                                              /*;AN000;*/
            status = p_syntax;                                         /*;AN000;*/
         else                                                          /*;AN000;*/
            status = p_no_error;                                       /*;AN000;*/
         strcpy(fix_es_reg,NUL);                                       /*;AN000;*/

         continue;  /* go back up to while loop */                     /*;AN000;*/
         }                                                             /*;AN000;*/

      /* Check for keyword (an attribute name - fourth positional) */
      else if (status == p_not_in_key) {                               /*;AN000;*/
         inregs.x.di = (WORD)&p_p2;   /* change control blocks to */   /*;AN000;*/
                                      /* be able to parse the keyword */
         inregs.x.cx = 0;       /* reset ordinal count */              /*;AN000;*/
         status = p_no_error;                                          /*;AN000;*/
         no_value = FALSE;   /* got keyword and equal sign */          /*;AN000;*/
         continue;                                                     /*;AN000;*/
         }                                                             /*;AN000;*/

      if (status == p_no_error) {                                      /*;AN000;*/
         inregs.x.cx = outregs.x.cx;       /* update CX for parser */  /*;AN000;*/
         inregs.x.si = outregs.x.si;       /* update SI for parser */  /*;AN000;*/
         }                                                             /*;AN000;*/
      }   /* while loop */                                             /*;AN000;*/

   /* check error status and if at end of line */
   if (status == p_rc_eol) {                                           /*;AN000;*/
      status = p_no_error;                                             /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check for filename on command line */
   if (!got_fn && status == p_no_error) {                              /*;AN000;*/
      status = p_op_missing;                                           /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check for keyword and equal sign but no value */
   if (!no_value) {                                                    /*;AN000;*/
      status = p_syntax;                                               /*;AN000;*/
      }                                                                /*;AN000;*/

   /* check for duplicate +R +R or +A +A or -A -A or -R -R */
   for (pr=0,mr=0,pa=0,ma=0,i=0; i<4; i++) {                           /*;AN000;*/
      if (p_mask[i] & READONLY)                                        /*;AN000;*/
         pr++;                                                         /*;AN000;*/
      if (m_mask[i] & READONLY)                                        /*;AN000;*/
         mr++;                                                         /*;AN000;*/
      if (p_mask[i] & ARCHIVE)                                         /*;AN000;*/
         pa++;                                                         /*;AN000;*/
      if (m_mask[i] & ARCHIVE)                                         /*;AN000;*/
         ma++;                                                         /*;AN000;*/
      }                                                                /*;AN000;*/
   if ((pr > 1) || (mr > 1) || (pa > 1) || (ma > 1)) {                 /*;AN000;*/
      status = p_syntax;                                               /*;AN000;*/
      }                                                                /*;AN000;*/
   else {                                                              /*;AN000;*/
      for (pmask=0,mmask=0,i=0; i<4; i++) {                            /*;AN000;*/
         pmask |= p_mask[i];                  /* combine masks */      /*;AN000;*/
         mmask |= m_mask[i];                                           /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/

   /* check for duplicate -R +R or -A +A */
   if ((pmask & mmask & READONLY) || (pmask & mmask & ARCHIVE)) {      /*;AN000;*/
      status = p_syntax;                                               /*;AN000;*/
      }                                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Determine_type()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Determines the type of the new value of an attribute being set by  */
/*        the user in terms of extended attribute types.                     */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Determine_type(parser_type,result_ptr)                                 /*;AN000;*/
   WORD parser_type;                                                   /*;AN000;*/
   WORD *result_ptr;                                                   /*;AN000;*/
{                                                                      /*;AN000;*/
   DWORD number;                                                       /*;AN000;*/
   char string[129];                                                   /*;AN000;*/

   switch(parser_type) {                                               /*;AN000;*/
      case p_number:                                                   /*;AN000;*/
         ext_attr_value_type = EAISBINARY;                             /*;AN000;*/
         number = (DWORD)*(DWORD *)result_ptr;                         /*;AN000;*/
         if (number > 0xffff) {                                        /*;AN000;*/
            ext_attr_value.ea_bin.length = 4;                          /*;AN000;*/
            ext_attr_value.ea_bin.dword = number;                      /*;AN000;*/
            }                                                          /*;AN000;*/
         else if (number > 0xff) {                                     /*;AN000;*/
            ext_attr_value.ea_bin.length = 2;                          /*;AN000;*/
            ext_attr_value.ea_bin.dword = number;                      /*;AN000;*/
            }                                                          /*;AN000;*/
         else {                                                        /*;AN000;*/
            ext_attr_value.ea_bin.length = 1;                          /*;AN000;*/
            ext_attr_value.ea_bin.dword = number;                      /*;AN000;*/
            }                                                          /*;AN000;*/
         break;                                                        /*;AN000;*/

      case p_complex:                                                  /*;AN000;*/

         /* Taken care of in Parse_it() */
         break;                                                        /*;AN000;*/

      case p_string:                                                   /*;AN000;*/
      case p_quoted_string:                                            /*;AN000;*/
         Get_far_str(string,result_ptr,0);                             /*;AN000;*/

         /* is the type EAISLOGICAL or EAISASCII */
         if (strcmp(string,"ON") == 0) {                               /*;AN000;*/
            ext_attr_value.ea_logical = TRUE;                          /*;AN000;*/
            ext_attr_value_type = EAISLOGICAL;                         /*;AN000;*/
            }                                                          /*;AN000;*/
         else if (strcmp(string,"OFF") == 0) {                         /*;AN000;*/
            ext_attr_value.ea_logical = FALSE;                         /*;AN000;*/
            ext_attr_value_type = EAISLOGICAL;                         /*;AN000;*/
            }                                                          /*;AN000;*/
         else {                                                        /*;AN000;*/
            strcpy(ext_attr_value.ea_ascii,string);                    /*;AN000;*/
            ext_attr_value_type = EAISASCII;                           /*;AN000;*/
            }                                                          /*;AN000;*/
         break;                                                        /*;AN000;*/

      default:                                                         /*;AN000;*/
         ext_attr_value_type = EAISUNDEF;                              /*;AN000;*/
         ext_attr_value.ea_undef = TRUE;                               /*;AN000;*/
         break;                                                        /*;AN000;*/
      }                                                                /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Make_fspec()                                     */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Makes a full path-filename from the filename & current directory   */
/*        information.                                                       */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Make_fspec(fspec)                                                 /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD Check_DBCS();       /* forward declaration */                  /*;AN000;*/

   char path[256];                                                     /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD i,j;                                                           /*;AN000;*/

   status = NOERROR;                                                   /*;AN000;*/

   strcpy(path,fspec);                                                 /*;AN000;*/

   /* Check if user did not enter a drive letter */
   if (fspec[1] != ':') {                                              /*;AN000;*/
      inregs.x.ax = 0x1900;         /* Get current drive */            /*;AN000;*/
      intdos(&inregs,&outregs);                                        /*;AN000;*/
      fspec[0] = 'A' + (outregs.x.ax & 0xff);                          /*;AN000;*/
      fspec[1] = ':';                                                  /*;AN000;*/
      fspec[2] = NUL;                                                  /*;AN000;*/
      strcat(fspec,path);                                              /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check if user didn't enter a path in filename */
   if (!Check_DBCS(fspec,2,'\\')) {                                    /*;AN000;*/
      strcpy(path,&fspec[2]);                                          /*;AN000;*/
      fspec[2] = '\\';                                                 /*;AN000;*/
      inregs.x.ax = 0x4700;            /* Get current directory */     /*;AN000;*/
      inregs.x.si = (WORD)(&fspec[3]);                                 /*;AN000;*/
      inregs.h.dl = fspec[0] - 'A' +1;                                 /*;AN000;*/
      intdos(&inregs,&outregs);                                        /*;AN000;*/
      status = outregs.x.ax;                                           /*;AN000;*/

      if (!(outregs.x.cflag & CARRY)) {                                /*;AN000;*/
         status = NOERROR;                                             /*;AN000;*/
         if (!Check_DBCS(fspec,strlen(fspec)-1,'\\'))                  /*;AN000;*/
            strcat(fspec,"\\");                                        /*;AN000;*/
         strcat(fspec,path);                                           /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/

   /* seperate the file specification into path and filename */
   for (i=strlen(fspec);(i>=0) && (!Check_DBCS(fspec,i,'\\')); i--)    /*;AN000;*/
      /* null statement */ ;                                           /*;AN000;*/
   i++;                                                                /*;AN000;*/
   j = 0;                                                              /*;AN000;*/
   while (fspec[i+j] != '\0') {                                        /*;AN000;*/
      file[j] = fspec[i+j];                                            /*;AN000;*/
      fspec[i+j] = '\0';                                               /*;AN000;*/
      j++;                                                             /*;AN000;*/
      }                                                                /*;AN000;*/
   file[j] = '\0';                                                     /*;AN000;*/

   /* Check for filenames of: . (current dir) .. (parent dir) */
   if (strcmp(file,".") == 0)                                          /*;AN001;*/
      strcpy(file,"*.*");                                              /*;AN001;*/
   else if (strcmp(file,"..") == 0) {                                  /*;AN001;*/
      strcat(fspec,"..\\");                                            /*;AN001;*/
      strcpy(file,"*.*");                                              /*;AN001;*/
      }

   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Dta_save()                                       */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*                  saves an area in the PSP, but who knows.                 */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Dta_save(t,l)
   char   *t;
   unsigned l;
{
   unsigned i;

   for (i = 0; i < l; i++) *(t+i) = getpspbyte(0x80+i)
      /* null statement */  ;
 }


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Dta_restore()                                    */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*              Restores the data that was saved in Dta_save().              */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Dta_restore(t,l)
   char     *t;
   unsigned l;
{
   unsigned i;

   for (i = 0; i < l; i++) putpspbyte(0x80+i,*(t+i))
      /* null statement */  ;
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Find_first()                                     */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Find_first(s,f,a)
   char  *s;
   char  *f;
   WORD  *a;
{
   WORD  status;
   WORD  i;
   WORD  o;
   char  *t;

   t = f;
   *f = '\0';

   inregs.x.ax = 0x4e00;             /* DOS find first */
   inregs.x.cx = (*a & 0x00ff );
   inregs.x.dx = (WORD)s;
   intdos(&inregs,&outregs);
   status = outregs.x.ax;

   /* Check for no errors */
   if (!(outregs.x.cflag & CARRY)) {
      for (i = 0; i < 14; i++)
          *f++ = getpspbyte(0x80+30+i);
      *a = getpspbyte(0x80+21);
      status = NOERROR;
      }
   return(status);
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Find_next()                                      */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Find_next(f,a)
   char  *f;
   WORD  *a;
{
   WORD  status;
   WORD  i;
   WORD  o;
   char  *t;

   t = f;
   *f = '\0';

   inregs.x.ax = 0x4f00;          /* DOS find next */
   intdos(&inregs,&outregs);
   status = outregs.x.ax;

   if (!(outregs.x.cflag & CARRY)) {
      for (i = 0; i < 14; i++)
          *f++ = getpspbyte(0x80+30+i);
      *a = getpspbyte(0x80+21);
      status = NOERROR;
      }
   return(status);
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Get_reg_attrib()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Does a DOS get attribute byte.                                   */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: return = 0                                                */
/*                                                                           */
/*    Error exit: return = error code                                        */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Get_reg_attrib(fspec,attr_byte)                                   /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
   BYTE *attr_byte;                                                    /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/

   inregs.x.ax = (WORD)0x4300;                                         /*;AN000;*/
   inregs.x.dx = (WORD)fspec;                                          /*;AN000;*/
   intdos(&inregs,&outregs);                                           /*;AN000;*/
   status = outregs.x.ax;                                              /*;AN000;*/

   /* Check for error */                                               /*;AN000;*/
   if (!(outregs.x.cflag & CARRY)) {                                   /*;AN000;*/
      *attr_byte = (BYTE)outregs.h.cl;                                 /*;AN000;*/
      status = NOERROR;                                                /*;AN000;*/
      }                                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Ext_open()                                       */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Does a DOS extended open of a filename and returns a file handle.*/
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: handle = file handle, return = 0                          */
/*                                                                           */
/*    Error exit: handle = ?; return = error code                            */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Ext_open(fspec,handle)                                            /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
   WORD *handle;                                                       /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/

   inregs.x.ax = (WORD)0x6c00;                                         /*;AN000;*/
   inregs.x.bx = (WORD)0x80;                                           /*;AN000;*/
   inregs.x.cx = (WORD)0x0;                                            /*;AN000;*/
   inregs.x.dx = (WORD)0x0101;                                         /*;AN000;*/
   inregs.x.si = (WORD)fspec;                                          /*;AN000;*/
   inregs.x.di = (WORD)&plist;                                         /*;AN000;*//*;AN000;*/
   intdos(&inregs,&outregs);                                           /*;AN000;*/
   status = outregs.x.ax;                                              /*;AN000;*/

   /* Check for error */                                               /*;AN000;*/
   if (!(outregs.x.cflag & CARRY)) {                                   /*;AN000;*/
      *handle = outregs.x.ax;                                          /*;AN000;*/
      status = NOERROR;                                                /*;AN000;*/
      }                                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Get_ext_attrib()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Does a DOS Get extended attributes and returns far ptr to list.  */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: handle = file handle, return = 0                          */
/*                                                                           */
/*    Error exit: handle = ?; return = error code                            */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Get_ext_attrib(handle,list_ptr,qlist_ptr)                         /*;AN000;*/
   WORD handle;                                                        /*;AN000;*/
   WORD far **list_ptr;   /* ptr to far ptr to list returned */        /*;AN000;*/
   WORD *qlist_ptr;       /* query list */                             /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD attr_size;                                                     /*;AN000;*/
   WORD *list_seg;                                                     /*;AN000;*/
   WORD *ptr;                                                          /*;AN000;*/

   /* get size of attribute list */                                    /*;AN000;*/
   inregs.x.bx = handle;                                               /*;AN000;*/
   inregs.x.ax = 0x5702;       /* Get extended attributes*/            /*;AN000;*/
   inregs.x.si = (WORD)qlist_ptr;   /* query one attribute */          /*;AN000;*/
   inregs.x.cx = (WORD)0;      /* just get size of return buffer */    /*;AN000;*/
   intdos(&inregs,&outregs);                                           /*;AN000;*/
   status = outregs.x.ax;                                              /*;AN000;*/

   /* if no errors then get extended attributes */
   if (!(outregs.x.cflag & CARRY)) {                                   /*;AN000;*/
      attr_size = outregs.x.cx;                                        /*;AN000;*/

      /* allocate buffer space for extended attr. list */
      /* uses MAX_ATTR_SIZE if possible so that buffer can be used */
      /* to set the largest attribute possible                     */
      if (attr_size > MAX_ATTR_SIZE)                                   /*;AN000;*/
          list_seg = Dallocate(attr_size);                             /*;AN000;*/
      else                                                             /*;AN000;*/
          list_seg = Dallocate(MAX_ATTR_SIZE);                         /*;AN000;*/

      /* get extended attributes */
      inregs.x.bx = handle;                                            /*;AN000;*/
      inregs.x.ax = 0x5702;       /* Get extended attributes */        /*;AN000;*/
      inregs.x.si = (WORD)qlist_ptr;   /* query one attribute */       /*;AN000;*/
      inregs.x.di = (WORD)0x0;    /* return buffer offset */           /*;AN000;*/
      inregs.x.cx = attr_size;    /* size to get all attributes */     /*;AN000;*/
      segregs.es = (WORD)list_seg; /* segment of ea list to return */  /*;AN000;*/
      intdosx(&inregs,&outregs,&segregs);                              /*;AN000;*/
      strcpy(fix_es_reg,NUL);    /* restores original ES reg. value */ /*;AN000;*/
      status = outregs.x.ax;                                           /*;AN000;*/

      /* if no errors then fix up far pointer to list */
      if (!(outregs.x.cflag & CARRY)) {                                /*;AN000;*/

         /* convert segment returned from Dallocate to far ptr */
         *list_ptr = 0;                                                /*;AN000;*/
         ptr = (WORD *)list_ptr;                                       /*;AN000;*/
         ptr++;                                                        /*;AN000;*/
         *ptr = (WORD)list_seg;                                        /*;AN000;*/
         (*list_ptr)++;                                                /*;AN000;*/
         strcpy(fix_es_reg,NUL);  /* restores ES register value */     /*;AN000;*/
         status = NOERROR;                                             /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Get_ext_attr_names()                             */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Does a DOS Get extended attribute names and return a far ptr to  */
/*          the querylist of names.                                          */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: handle = file handle, return = 0                          */
/*                                                                           */
/*    Error exit: handle = ?; return = error code                            */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Get_ext_attr_names(handle,list_ptr,num_entries)                   /*;AN000;*/
   WORD handle;                                                        /*;AN000;*/
   WORD far **list_ptr;   /* ptr to far ptr to list returned */        /*;AN000;*/
   WORD *num_entries;     /* number of entries in list */              /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD attr_size;                                                     /*;AN000;*/
   WORD *list_seg;                                                     /*;AN000;*/
   WORD *ptr;                                                          /*;AN000;*/

   /* get size of attribute name list */                               /*;AN000;*/
   inregs.x.bx = handle;                                               /*;AN000;*/
   inregs.x.ax = 0x5703;       /* Get extended attribute names */      /*;AN000;*/
   inregs.x.cx = (WORD)0;      /* just get size of return buffer */    /*;AN000;*/
   intdos(&inregs,&outregs);                                           /*;AN000;*/
   status = outregs.x.ax;                                              /*;AN000;*/

   /* if no errors then get extended attribute names */
   if (!(outregs.x.cflag & CARRY)) {                                   /*;AN000;*/
      attr_size = outregs.x.cx;                                        /*;AN000;*/

      /* allocate buffer space for extended attr. list */
      list_seg = Dallocate(attr_size);                                 /*;AN000;*/

      /* get extended attributes */
      inregs.x.bx = handle;                                            /*;AN000;*/
      inregs.x.ax = 0x5703;       /* Get extended attributes */        /*;AN000;*/
      inregs.x.di = (WORD)0x0;    /* return buffer offset */           /*;AN000;*/
      inregs.x.cx = attr_size;    /* size to get all names */          /*;AN000;*/
      segregs.es = (WORD)list_seg; /* segment of ea list to return */  /*;AN000;*/
      intdosx(&inregs,&outregs,&segregs);                              /*;AN000;*/
      strcpy(fix_es_reg,NUL);    /* restores original ES reg. value */ /*;AN000;*/
      status = outregs.x.ax;                                           /*;AN000;*/
      *num_entries = 0;                                                /*;AN000;*/

      /* if no errors then fix up far pointer to list */
      if (!(outregs.x.cflag & CARRY)) {                                /*;AN000;*/

         /* convert segment returned from Dallocate to far ptr */
         *list_ptr = 0;                                                /*;AN000;*/
         ptr = (WORD *)list_ptr;                                       /*;AN000;*/
         ptr++;                                                        /*;AN000;*/
         *ptr = (WORD)list_seg;                                        /*;AN000;*/
         *num_entries = (WORD)*(WORD far *)*list_ptr;                  /*;AN000;*/
         (*list_ptr)++;                                                /*;AN000;*/
         strcpy(fix_es_reg,NUL);  /* restores ES register value */     /*;AN000;*/
         status = NOERROR;                                             /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Set_reg_attrib()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Sets the attribute byte of a file (not extended attributes).     */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Set_reg_attrib(fspec,attr_byte)                                   /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
   BYTE attr_byte;                                                     /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/

   /* set attribute byte (archive & read-only bits) */
   inregs.x.ax = 0x4301;          /* do DOS chmod call  */             /*;AN000;*/
   inregs.x.dx = (WORD)fspec;                                          /*;AN000;*/
   inregs.h.ch = 0x0;                                                  /*;AN000;*/
   inregs.h.cl = (BYTE)attr_byte;                                      /*;AN000;*/
   intdos(&inregs,&outregs);                                           /*;AN000;*/
   status = outregs.x.ax;                                              /*;AN000;*/
                                                                       /*;AN000;*/
   /* Check for error */
   if (!(outregs.x.cflag & CARRY))
      status = NOERROR;                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Set_ext_attrib()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Set an extended attribute for a file.                            */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Set_ext_attrib(handle,list_ptr)                                   /*;AN000;*/
   WORD handle;                                                        /*;AN000;*/
   WORD far *list_ptr;                                                 /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/

   /* set extended attribute */
   inregs.x.ax = 0x5704;          /* DOS set ext. attr. */             /*;AN000;*/
   inregs.x.bx = handle;                                               /*;AN000;*/
   inregs.x.di = 0x0;                    /* list offset */             /*;AN000;*/
   segregs.es = (WORD)FP_SEG(list_ptr);  /* list segment */            /*;AN000;*/
   intdosx(&inregs,&outregs,&segregs);                                 /*;AN000;*/
   status = outregs.x.ax;                                              /*;AN000;*/
                                                                       /*;AN000;*/
   /* Check for error */
   if (!(outregs.x.cflag & CARRY))                                     /*;AN000;*/
      status = NOERROR;                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     CheckYN()                                        */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Check for a valid Yes/No answer.                                 */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD CheckYN(fspec)                                                    /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD answer;                                                        /*;AN000;*/
   WORD key;                                                           /*;AN000;*/

   while (TRUE) {                                                      /*;AN000;*/
      msg_str2.sub_value_seg = segregs.ds;                             /*;AN000;*/
      msg_str2.sub_value = (WORD)fspec;                                /*;AN000;*/
      Display_msg(11,STDOUT,ONEPARM,&msg_str2,INPUT);                  /*;AN000;*/
      key = outregs.x.ax;          /* get key from AX */               /*;AN000;*/
      inregs.x.dx = key;           /* put key in DX */                 /*;AN000;*/
      inregs.x.ax = 0x6523;        /* check Y/N */                     /*;AN000;*/
      intdos(&inregs,&outregs);                                        /*;AN000;*/
      answer = outregs.x.ax;                                           /*;AN000;*/
      Display_msg(14,STDOUT,NOSUBPTR,NOSUBCNT,NOINPUT);                /*;AN000;*/

      if (answer == YES || answer == NO)                               /*;AN000;*/
         break;                                                        /*;AN000;*/
      }                                                                /*;AN000;*/
   return(answer);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Find_ext_attrib()                                */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Given an extended attribute name, search the list of attributes    */
/*        for a file to find this attribute. Return either TRUE for found    */
/*        or FALSE for not found.                                            */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Find_ext_attrib(lptr,attribute,num,addr)                          /*;AN000;*/
   WORD far *lptr;                                                     /*;AN000;*/
   char *attribute;                                                    /*;AN000;*/
   WORD num;                                                           /*;AN000;*/
   struct name_list far **addr;                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   struct name_list far *ptr;                                          /*;AN000;*/
   WORD   i,j;                                                         /*;AN000;*/
   WORD   length;                                                      /*;AN000;*/
   WORD   found;                                                       /*;AN000;*/
   WORD   match;                                                       /*;AN000;*/

   found = FALSE;                                                      /*;AN000;*/

   /* loop thru return list structure for the ext. attr. we want */
   for (ptr = (struct name_list far *)lptr,i=0;i < num; i++) {         /*;AN000;*/

      /* compare attribute name to see if this is it */
      if (ptr->nl_name_len == (length = strlen(attribute))) {          /*;AN000;*/
         match = TRUE;                                                 /*;AN000;*/
         for (j=0;j<length ;j++) {                                     /*;AN000;*/
            if (ptr->nl_name[j] != attribute[j]) {                     /*;AN000;*/
               match = FALSE;                                          /*;AN000;*/
               break;                                                  /*;AN000;*/
               }                                                       /*;AN000;*/
            }                                                          /*;AN000;*/
         if (match) {                                                  /*;AN000;*/
            found = TRUE;                                              /*;AN000;*/
            break;                                                     /*;AN000;*/
            }                                                          /*;AN000;*/
         }                                                             /*;AN000;*/

      /* advance ptr to next extended attr. structure */
      length = NAME_SIZE + ptr->nl_name_len;                           /*;AN000;*/
      ptr = (struct name_list far *)((BYTE far *)ptr + length);        /*;AN000;*/
      strcpy(fix_es_reg,NUL);                                          /*;AN000;*/
      }                                                                /*;AN000;*/

   /* found the extended attribute wanted, pass addr back */
   if (found) {                                                        /*;AN000;*/
      *addr = ptr;                                                     /*;AN000;*/
      }                                                                /*;AN000;*/
   strcpy(fix_es_reg,NUL);                                             /*;AN000;*/
   return(found);                                                      /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Print_ext_attrib()                               */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Given an extended attribute name, search the list of attributes    */
/*        for a file to find this attribute. Return either TRUE for found    */
/*        or FALSE for not found.                                            */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: target = source                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Print_ext_attrib(fspec,type,name_ptr,num,attr_ptr)                /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
   WORD type;                                                          /*;AN000;*/
   struct name_list far *name_ptr;                                     /*;AN000;*/
   WORD num;                                                           /*;AN000;*/
   struct attr_list far *attr_ptr;                                     /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD i;                                                             /*;AN000;*/
   WORD length;                                                        /*;AN000;*/
   WORD value;                                                         /*;AN000;*/
   BYTE far *value_ptr;                                                /*;AN000;*/
   char string[129];                                                   /*;AN000;*/
   char far *cptr;                                                     /*;AN000;*/
   struct name_list far *ptr;                                          /*;AN000;*/

   /* find value field in attribute list */
   length = ATTR_SIZE + attr_ptr->at_name_len;                         /*;AN000;*/
   value_ptr = (BYTE far *)((BYTE far *)attr_ptr + length);            /*;AN000;*/
   length = attr_ptr->at_value_len;                                    /*;AN000;*/
   strcpy(fix_es_reg,NUL);                                             /*;AN000;*/

   status = NOERROR;                                                   /*;AN000;*/
   switch (type) {                                                     /*;AN000;*/
      case EAISUNDEF:                                                  /*;AN000;*/
         msg_str2.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str2.sub_value = (WORD)fspec;                             /*;AN000;*/
         Display_msg(12,STDOUT,ONEPARM,&msg_str2,NOINPUT);             /*;AN000;*/
         break;                                                        /*;AN000;*/
      case EAISLOGICAL:                                                /*;AN000;*/
         msg_str.sub_value_seg = segregs.ds;                           /*;AN000;*/
         if ((BYTE)*(BYTE far *)value_ptr == 0)                        /*;AN000;*/
            msg_str.sub_value = (WORD)str_off;                         /*;AN000;*/
         else                                                          /*;AN000;*/
            msg_str.sub_value = (WORD)str_on;                          /*;AN000;*/
         msg_str1.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str1.sub_value = (WORD)fspec;                             /*;AN000;*/
         Display_msg(9,STDOUT,TWOPARM,&msg_str,NOINPUT);               /*;AN000;*/
         break;                                                        /*;AN000;*/
      case EAISBINARY:                                                 /*;AN000;*/
         if (length == 1) {                                            /*;AN000;*/
            msg_num.sub_flags = sf_unsbin2d | sf_byte | sf_right;      /*;AN000;*/
            value = (BYTE)*(BYTE far *)value_ptr;                      /*;AN000;*/
            }                                                          /*;AN000;*/
         else if (length == 2) {                                       /*;AN000;*/
            msg_num.sub_flags = sf_unsbin2d | sf_word | sf_right;      /*;AN000;*/
            value = (WORD)*(WORD far *)value_ptr;                      /*;AN000;*/
            }                                                          /*;AN000;*/
         else if (length == 4) {                                       /*;AN000;*/
            msg_num.sub_flags = sf_unsbin2d | sf_dword | sf_right;     /*;AN000;*/
            value = (DWORD)*(DWORD far *)value_ptr;                    /*;AN000;*/
            }                                                          /*;AN000;*/
         msg_num.sub_value_seg = segregs.ds;                           /*;AN000;*/
         msg_num.sub_value = (WORD)&value;                             /*;AN000;*/
         msg_str1.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str1.sub_value = (WORD)fspec;                             /*;AN000;*/
         Display_msg(9,STDOUT,TWOPARM,&msg_num,NOINPUT);               /*;AN000;*/
         break;                                                        /*;AN000;*/
      case EAISASCII:                                                  /*;AN000;*/
         msg_str2.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str2.sub_value = (WORD)fspec;                             /*;AN000;*/
         Display_msg(12,STDOUT,ONEPARM,&msg_str2,NOINPUT);             /*;AN000;*/
         Get_far_str(string,&value_ptr,length);                        /*;AN000;*/
         msg_str2.sub_value = (WORD)string;                            /*;AN000;*/
         Display_msg(8,STDOUT,ONEPARM,&msg_str2,NOINPUT);              /*;AN000;*/
         break;                                                        /*;AN000;*/
      case EAISDATE:                                                   /*;AN000;*/
         msg_str1.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str1.sub_value = (WORD)fspec;                             /*;AN000;*/
         value = (WORD)*(WORD far *)value_ptr;                         /*;AN000;*/
         Convert_date(value,&msg_date.sub_value,&msg_date.sub_value_seg); /*;AN000;*/
         Display_msg(9,STDOUT,TWOPARM,&msg_date,NOINPUT);              /*;AN000;*/
         break;                                                        /*;AN000;*/
      case EAISTIME:                                                   /*;AN000;*/
         msg_str1.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str1.sub_value = (WORD)fspec;                             /*;AN000;*/
         value = (WORD)*(WORD far *)value_ptr;                         /*;AN000;*/
         Convert_time(value,&msg_time.sub_value,&msg_time.sub_value_seg); /*;AN000;*/
         Display_msg(9,STDOUT,TWOPARM,&msg_time,NOINPUT);              /*;AN000;*/
         break;                                                        /*;AN000;*/
      case EANAMES:                                                    /*;AN000;*/
         msg_str2.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str2.sub_value = (WORD)fspec;                             /*;AN000;*/
         Display_msg(12,STDOUT,ONEPARM,&msg_str2,NOINPUT);             /*;AN000;*/

         /* display special attribute names */
         for (i=0; i < MAX_SPL; i++) {                                 /*;AN000;*/
            msg_str2.sub_value = (WORD)specials[i].name;               /*;AN000;*/
            Display_msg(8,STDOUT,ONEPARM,&msg_str2,NOINPUT);           /*;AN000;*/
            }                                                          /*;AN000;*/

         /* display each attribute name */
         for (ptr = name_ptr,i=0; i<num; i++) {                        /*;AN000;*/
            cptr = (char far *)((BYTE far *)ptr + 4);                  /*;AN000;*/
            Get_far_str(string,&cptr,(WORD)ptr->nl_name_len);          /*;AN000;*/

            msg_str2.sub_value = (WORD)string;                         /*;AN000;*/
            Display_msg(8,STDOUT,ONEPARM,&msg_str2,NOINPUT);           /*;AN000;*/

            /* advance ptr to next extended attr. structure */
            length = NAME_SIZE + ptr->nl_name_len;                     /*;AN000;*/
            ptr = (struct name_list far *)((BYTE far *)ptr + length);  /*;AN000;*/
            strcpy(fix_es_reg,NUL);                                    /*;AN000;*/
            }                                                          /*;AN000;*/
         Display_msg(14,STDOUT,NOSUBPTR,NOSUBCNT,NOINPUT);             /*;AN000;*/
         Display_msg(14,STDOUT,NOSUBPTR,NOSUBCNT,NOINPUT);             /*;AN000;*/
         break;                                                        /*;AN000;*/
      default:                                                         /*;AN000;*/
         msg_str2.sub_value_seg = segregs.ds;                          /*;AN000;*/
         msg_str2.sub_value = (WORD)fspec;                             /*;AN000;*/
         Display_msg(12,STDOUT,ONEPARM,&msg_str2,NOINPUT);             /*;AN000;*/
         break;                                                        /*;AN000;*/
      } /* endswitch */                                                /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/

/*���������������������������������������������������������������������������*/
/*                                                                           */
/*    Subroutine Name: Convert_date                                          */
/*                                                                           */
/*    Subroutine Function:                                                   */
/*       Convert date word returned by DOS to the form required by the       */
/*       message retriever.                                                  */
/*                                                                           */
/*       DOS returns:   yyyyyyym mmmddddd                                    */
/*                                                                           */
/*                      y = 0-119 (1980-2099)                                */
/*                      m = 1-12                                             */
/*                      d = 1-31                                             */
/*                                                                           */
/*       Message retriever requires:  yyyyyyyy yyyyyyyy mmmmmmmm dddddddd    */
/*                                                                           */
/*    Input:                                                                 */
/*        (1) Date word in form given by DOS                                 */
/*        (2) Address of first word to place result (yyyyyyyy yyyyyyyy)      */
/*        (3) Address of second word to place result (mmmmmmmm dddddddd)     */
/*                                                                           */
/*    Output:                                                                */
/*        Double word result updated with date in form required by           */
/*        message retriever.                                                 */
/*                                                                           */
/*    Normal exit: Result word updated                                       */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Convert_date(dosdate,msgdate1,msgdate2)
   WORD dosdate;
   WORD *msgdate1;
   WORD *msgdate2;
{
   WORD     day,month,year;

   year = dosdate;
   year = ((year >> 1) & 0x7f00) + 80*256;   /* DOS year + 80 */
   year = (year >> 8) & 0x007f;                                        /*;AN000;*/
   day = dosdate;
   day = (day << 8) & 0x1f00;
   month = dosdate;
   month = (month >> 5) & 0x000f;
   *msgdate1 = year;
   *msgdate2 = month | day;
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*    Subroutine Name: Convert_time                                          */
/*                                                                           */
/*    Subroutine Function:                                                   */
/*       Convert time word returned by DOS to the form required by the       */
/*       message retriever.                                                  */
/*                                                                           */
/*       DOS returns:   hhhhhmmm mmmsssss                                    */
/*                                                                           */
/*                      h = hours (0-23)                                     */
/*                      m = minutes (0-59)                                   */
/*                      s = seconds/2                                        */
/*                                                                           */
/*       Message retriever requires:  hhhhhhhh mmmmmmmm ssssssss hhhhhhhh    */
/*                                                                           */
/*    Input:                                                                 */
/*        (1) Time word in form given by DOS                                 */
/*        (2) Address of first word to place result (hhhhhhhh hhhhhhhh)      */
/*        (3) Address of second word to place result (ssssssss 00000000)     */
/*                                                                           */
/*    Output:                                                                */
/*        Double word result updated with time in form required by           */
/*        message retriever.                                                 */
/*                                                                           */
/*    Normal exit: Result word updated                                       */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Convert_time(dostime,msgtime1,msgtime2)
   WORD dostime;
   WORD *msgtime1;
   WORD *msgtime2;
{
   WORD     hours,minutes,seconds;

   hours = dostime;
   hours = hours >> 11 & 0x001f;
   seconds = dostime;
   seconds = seconds & 0x001f * 2;   /* seconds * 2 */
   minutes = dostime;
   minutes = minutes << 3 & 0x3f00;
   *msgtime1 = hours | minutes;
   *msgtime2 = seconds;
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Regular_attrib()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Handles all function for archive bit and read-only bit.            */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Regular_attrib(fspec)                                             /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD i;                                                             /*;AN000;*/
   char string[16];                                                    /*;AN000;*/

   /* get attributes */
   if ((status = Get_reg_attrib(fspec,&attr)) != NOERROR) {            /*;AN000;*/
      return(status);                                                  /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check whether to display values or set new ones */
   if (set_reg_attr) {                                                 /*;AN000;*/
      attr = (attr & (~mmask)) | pmask;                                /*;AN000;*/
      status = Set_reg_attrib(fspec,attr);                             /*;AN000;*/
      }                                                                /*;AN000;*/
   else {                                                              /*;AN000;*/
      for (i = 0; i < 8; i++)                                          /*;AN000;*/
         if ((attr & bits[i]) != 0 )                                   /*;AN000;*/
            string[i] = as[i];                                         /*;AN000;*/
         else                                                          /*;AN000;*/
            string[i] = ' ';                                           /*;AN000;*/
      for (i=8; i < 16; i++)                                           /*;AN000;*/
         string[i] = ' ';                                              /*;AN000;*/
      string[16] = '\0';                                               /*;AN000;*/

      msg_str.sub_value_seg = segregs.ds;                              /*;AN000;*/
      msg_str.sub_value = (WORD)string;                                /*;AN000;*/
      msg_str1.sub_value_seg = segregs.ds;                             /*;AN000;*/
      msg_str1.sub_value = (WORD)fspec;                                /*;AN000;*/
      Display_msg(9,STDOUT,TWOPARM,&msg_str,NOINPUT);                  /*;AN000;*/
      }                                                                /*;AN000;*/

   did_attrib_ok = TRUE;                                               /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Special_attrib()                                 */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Handles all function for special attributes. For example, "DATE" */
/*          is a special attribute because it is not an extended attribute,  */
/*          but ATTRIB does support its function.                            */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Special_attrib(handle,fspec,id)                                   /*;AN000;*/
   WORD handle;                                                        /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
   WORD id;                                                            /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   DWORD filesize;                                                     /*;AN000;*/
   long size;                                                          /*;AN000;*/
   long filelength();                                                  /*;AN000;*/

   msg_str1.sub_value_seg = segregs.ds;                                /*;AN000;*/
   msg_str1.sub_value = (WORD)fspec;                                   /*;AN000;*/

   /* check to set if user is trying to set a special attribute, if so */
   /* then return error.                                               */
   if (set_ext_attr)                                                   /*;AN000;*/
      return(EARCNOTEVER+200);                                         /*;AN000;*/

   /* determine which info to get by using ID */
   if (id == A_FILESIZE) {       /* get filesize */                    /*;AN000;*/

      /* get file size, if error return error code */
      if ((size = filelength(handle)) == (long)-1) {                   /*;AN000;*/
         return(FILENOTFOUND);                                         /*;AN000;*/
         }                                                             /*;AN000;*/
      filesize = (DWORD)size;                                          /*;AN000;*/
      msg_dword.sub_value = (WORD)&filesize;                           /*;AN000;*/
      msg_dword.sub_value_seg = (WORD)segregs.ds;                      /*;AN000;*/
      Display_msg(9,STDOUT,TWOPARM,&msg_dword,NOINPUT);                /*;AN000;*/
      }                                                                /*;AN000;*/

   else if (id == A_DATE) {                                            /*;AN000;*/
      inregs.x.ax = 0x5700;      /* get date */                        /*;AN000;*/
      inregs.x.bx = handle;                                            /*;AN000;*/
      intdos(&inregs,&outregs);                                        /*;AN000;*/
      status = outregs.x.ax;                                           /*;AN000;*/
      if (outregs.x.cflag & CARRY)                                     /*;AN000;*/
         return(status);                                               /*;AN000;*/

      Convert_date(outregs.x.dx,&msg_date.sub_value,&msg_date.sub_value_seg); /*;AN000;*/
      Display_msg(9,STDOUT,TWOPARM,&msg_date,NOINPUT);                 /*;AN000;*/
      }                                                                /*;AN000;*/

   else if (id == A_TIME) {                                            /*;AN000;*/
      inregs.x.ax = 0x5700;      /* get time */                        /*;AN000;*/
      inregs.x.bx = handle;                                            /*;AN000;*/
      intdos(&inregs,&outregs);                                        /*;AN000;*/
      status = outregs.x.ax;                                           /*;AN000;*/
      if (outregs.x.cflag & CARRY)                                     /*;AN000;*/
         return(status);                                               /*;AN000;*/

      Convert_time(outregs.x.cx,&msg_time.sub_value,&msg_time.sub_value_seg); /*;AN000;*/
      Display_msg(9,STDOUT,TWOPARM,&msg_time,NOINPUT);                 /*;AN000;*/
      }                                                                /*;AN000;*/

   did_attrib_ok = TRUE;                                               /*;AN000;*/
   return(NOERROR);                                                    /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Extended_attrib()                                */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Determine what functions the user wants and then gets the        */
/*          extended attributes and regular attributes and then checks       */
/*          the attributes against what the user wanted and either do it or  */
/*          return error.                                                    */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Extended_attrib(handle,fspec)                                     /*;AN000;*/
   WORD handle;                                                        /*;AN000;*/
   char *fspec;                                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD num;                                                           /*;AN000;*/
   WORD type;                                                          /*;AN000;*/
   WORD length;                                                        /*;AN000;*/
   WORD i;                                                             /*;AN000;*/
   WORD far *name_ptr,                                                 /*;AN000;*/
        far *nptr;                                                     /*;AN000;*/
   WORD far *list_ptr;                                                 /*;AN000;*/
   BYTE far *value_ptr;                                                /*;AN000;*/
   char far *cptr;                                                     /*;AN000;*/
   char *ptr;                                                          /*;AN000;*/
   struct query_list qlist;                                            /*;AN000;*/

   /* get extended attribute names, if error return with error code */
   if ((status = Get_ext_attr_names(handle,&name_ptr,&num)) != NOERROR) { /*;AN000;*/
      return(status);                                                  /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check for keyword "*", print all extended attribute names */
   /* ***** this is a special piece of code                     */
   if (strcmp(ext_attr,"*") == 0) {                                    /*;AN000;*/
      do_ext_attr = TRUE;                                              /*;AN000;*/
      set_ext_attr = FALSE;                                            /*;AN000;*/
      nptr = name_ptr;                                                 /*;AN000;*/
      type = EANAMES;                                                  /*;AN000;*/
      status = Print_ext_attrib(fspec,type,name_ptr,num,list_ptr);     /*;AN004;*/
      did_attrib_ok = TRUE;                                            /*;AN004;*/
      return(status);                                                  /*;AN004;*/
      }                                                                /*;AN000;*/

   /* find if extended attribute name is in list */
   else if (!Find_ext_attrib(name_ptr,ext_attr,num,&nptr)) {           /*;AN000;*/
      return(EARCNOTFOUND+200);                                        /*;AN000;*/
      }                                                                /*;AN000;*/
   else                                                                /*;AN000;*/
      type = ((struct name_list far *)nptr)->nl_type;                  /*;AN000;*/

   /* Check if extended attribute is hidden , if so leave */
   if (((struct name_list far *)nptr)->nl_flags & EAHIDDEN) {          /*;AN000;*/
      did_attrib_ok = TRUE;                                            /*;AN000;*/
      return(NOERROR);                                                 /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Get the extended attribute value */
   qlist.ql_num = 1;                                                   /*;AN000;*/
   qlist.ql_type = ((struct name_list far *)nptr)->nl_type;            /*;AN000;*/
   qlist.ql_flags = ((struct name_list far *)nptr)->nl_flags;          /*;AN000;*/
   qlist.ql_name_len = ((struct name_list far *)nptr)->nl_name_len;    /*;AN000;*/
   cptr = (char far *)((BYTE far *)nptr + 4);                          /*;AN000;*/
   Get_far_str(qlist.ql_name,&cptr,qlist.ql_name_len);                 /*;AN000;*/

   if ((status = Get_ext_attrib(handle,&list_ptr,&qlist)) != NOERROR) { /*;AN000;*/
      return(status);                                                  /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check if doing a display or set, and go do it */
   if (do_ext_attr) {                                                  /*;AN000;*/
      status = Print_ext_attrib(fspec,type,name_ptr,num,list_ptr);     /*;AN000;*/
      }                                                                /*;AN000;*/
   else {                                                              /*;AN000;*/

      /* Check if extended attribute is read-only or create-only */
      /* or if the type is undefined. if true, display error     */
      if ((qlist.ql_flags & (EAREADONLY | EACREATEONLY)) ||            /*;AN000;*/
                                     (qlist.ql_type & EAISUNDEF)) {    /*;AN000;*/
         return(EARCNOTEVER+200); /* error will be displayed */        /*;AN000;*/
         }                                                             /*;AN000;*/

      /* Check type of current attribute against the type the user */
      /* is trying to set the attribute to. If they differ, error. */
      if (qlist.ql_type != ext_attr_value_type) {                      /*;AN000;*/
         return(EARCDEFBAD+200);  /* error will be displayed */        /*;AN000;*/
         }                                                             /*;AN000;*/

      /* find value field in attribute list */
      length = ATTR_SIZE + qlist.ql_name_len;                          /*;AN000;*/
      value_ptr = (BYTE far *)((BYTE far *)list_ptr + length);         /*;AN000;*/
      length = ((struct attr_list far *)list_ptr)->at_value_len;       /*;AN000;*/
      strcpy(fix_es_reg,NUL);                                          /*;AN000;*/

      /* CODEPAGE attrbute only - display Y/N message if changing codepage */
      /* to a new value and cp != 0, ask for confirmation.                 */
      if (strcmp(qlist.ql_name,"CP") == 0 &&                           /*;AN000;*/
           (WORD)*(WORD far *)value_ptr != 0 &&                        /*;AN000;*/
           (WORD)*(WORD far *)value_ptr != (WORD)ext_attr_value.ea_bin.dword) { /*;AN000;*/
         if (CheckYN(fspec) == NO) {                                   /*;AN000;*/
            did_attrib_ok = TRUE;                                      /*;AN000;*/
            return(NOERROR);                                           /*;AN000;*/
            }                                                          /*;AN000;*/
         }                                                             /*;AN000;*/

      /* Determine type of extended attribute and set the correct value */
      switch (ext_attr_value_type) {                                   /*;AN000;*/
         case EAISLOGICAL:                                             /*;AN000;*/
            *(BYTE far *)value_ptr = (BYTE)ext_attr_value.ea_logical;  /*;AN000;*/
            break;                                                     /*;AN000;*/
         case EAISBINARY:                                              /*;AN000;*/
            if (length == 1)                                           /*;AN000;*/
               *(BYTE far *)value_ptr = (BYTE)ext_attr_value.ea_bin.dword; /*;AN000;*/
            else if (length == 2)                                      /*;AN000;*/
               *(WORD far *)value_ptr = (WORD)ext_attr_value.ea_bin.dword; /*;AN000;*/
            else                                                       /*;AN000;*/
               *(DWORD far *)value_ptr = (DWORD)ext_attr_value.ea_bin.dword; /*;AN000;*/
            break;                                                     /*;AN000;*/
         case EAISASCII:                                               /*;AN000;*/
            length = strlen(ext_attr_value.ea_ascii); /* get string length */ /*;AN000;*/
            ((struct attr_list far *)list_ptr)->at_value_len = length; /*;AN000;*/
            for (ptr=ext_attr_value.ea_ascii,i=0;i < length;i++) {     /*;AN000;*/
               *(char far *)value_ptr = *ptr++;                        /*;AN000;*/
               ((char far *)value_ptr)++;                              /*;AN000;*/
               }                                                       /*;AN000;*/
            break;                                                     /*;AN000;*/
         case EAISDATE:                                                /*;AN000;*/
            *(WORD far *)value_ptr = (WORD)ext_attr_value.ea_date;     /*;AN000;*/
            break;                                                     /*;AN000;*/
         case EAISTIME:                                                /*;AN000;*/
            *(WORD far *)value_ptr = (WORD)ext_attr_value.ea_time;     /*;AN000;*/
            break;                                                     /*;AN000;*/
         }                                                             /*;AN000;*/

      list_ptr--;           /* make list_ptr point to num entries */   /*;AN000;*/
      *(WORD far *)list_ptr = 1;      /* num entries = 1 */            /*;AN000;*/

      if ((status = Set_ext_attrib(handle,list_ptr)) != NOERROR) {     /*;AN000;*/
         return(status);                                               /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/
   did_attrib_ok = TRUE;                                               /*;AN000;*/
   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Attrib()                                         */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*          Determine what functions the user wants and then gets the        */
/*          extended attributes and regular attributes and then checks       */
/*          the attributes against what the user wanted and either do it or  */
/*          return error.                                                    */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Attrib(path,file)                                                 /*;AN000;*/
   char *path,                                                         /*;AN000;*/
        *file;                                                         /*;AN000;*/
{                                                                      /*;AN000;*/
   char fspec[128];                                                    /*;AN000;*/
   WORD status;                                                        /*;AN000;*/
   WORD handle;                                                        /*;AN000;*/
   WORD i;                                                             /*;AN000;*/
   WORD found_spl;        /* boolean */                                /*;AN000;*/
   WORD id;                                                            /*;AN000;*/

   strcpy(fspec,path);     /* make full filename */                    /*;AN000;*/
   strcat(fspec,file);                                                 /*;AN000;*/

   /* Check for extended & special attributes */
   if (set_ext_attr || do_ext_attr) {                                  /*;AN000;*/

      /* Check for special attribute keywords */
      found_spl = FALSE;                                               /*;AN000;*/
      for (i=0; i < MAX_SPL; i++) {                                    /*;AN000;*/
         if (strcmp(ext_attr,specials[i].name) == 0) {                 /*;AN000;*/
            found_spl = TRUE;                                          /*;AN000;*/
            id = specials[i].id;                                       /*;AN000;*/
            break;                                                     /*;AN000;*/
            }                                                          /*;AN000;*/
         }                                                             /*;AN000;*/

      /* Do an extended open, if error return error code */
      if ((status = Ext_open(fspec,&handle)) != NOERROR) {             /*;AN000;*/
         return(status);                                               /*;AN000;*/
         }                                                             /*;AN000;*/

      /* Special attributes */
      if (found_spl) {                                                 /*;AN000;*/
         status = Special_attrib(handle,fspec,id);                     /*;AN000;*/
         }                                                             /*;AN000;*/

      /* Extended attributes */
      else {                                                           /*;AN000;*/
         status = Extended_attrib(handle,fspec);                       /*;AN000;*/
         }                                                             /*;AN000;*/
      close(handle);                                                   /*;AN000;*/
      }                                                                /*;AN000;*/

   /* Check if setting archive bit or readonly bit */
   if (set_reg_attr || do_reg_attr) {                                  /*;AN000;*/
      if ((status = Regular_attrib(fspec)) != NOERROR) {               /*;AN000;*/
         return(status);                                               /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/

   return(status);                                                     /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Do_dir()                                         */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Given the full path-filename, determine if descending option is    */
/*        set and then recursively (if option set) find all files in this    */
/*        directory and all files in any subdirectories (if option set).     */
/*        For each directory call Attrib()  which will process a file.       */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

WORD Do_dir(path,file)
   char *path,
        *file;
{
   char     dta_area[128];
   char     subdirectory[256];
   char     next[32];
   WORD     status;
   WORD     search_attrib;

   next[0] = '\0';                                                     /*;AN000;*/
   Dta_save(dta_area,128);
   status = NOERROR;                                                   /*;AN000;*/

   /* first, but only if descending, scan for subdirectories */
   if (descending) {
      strcpy(subdirectory,path);
      strcat(subdirectory,"*.*");

      search_attrib = SUBDIR; /* Find all except volume labels*/       /*;AN000;*/
      status = Find_first(subdirectory,next,&search_attrib);

      while (status == NOERROR) {
         if ((next[0] != '.') && ((search_attrib & SUBDIR) != 0)) {
             strcpy(subdirectory,path);
             strcat(subdirectory,next);
             strcat(subdirectory,"\\");
             status = Do_dir(subdirectory,file);
             }
         if (status == NOERROR) {
            strcpy(subdirectory,path);
            strcat(subdirectory,"*.*");

            search_attrib = SUBDIR;                                    /*;AN000;*/
            status = Find_next(next,&search_attrib);
            }
         }     /* while */
      }     /* if descending */

   if (status == NOMOREFILES)
      status = NOERROR;

   /* now, search this directory for files that match */
   if (status == NOERROR) {
      strcpy(subdirectory,path);
      strcat(subdirectory,file);

      search_attrib = SUBDIR;                                          /*;AN000;*/
      status = Find_first(subdirectory,next,&search_attrib);
      while(status == NOERROR) {

         /* Check that this file is not a directory, system file, */
         /* or a hidden file.                                     */
         if (  (next[0] != '.') &&
               ((search_attrib & SUBDIR) == 0) &&
               ((search_attrib & SYSTEM) == 0) &&
               ((search_attrib & HIDDEN) == 0) )  {
            status = Attrib(path,next);
            }

         if (status == NOERROR) {
            search_attrib = SUBDIR;                                    /*;AN000;*/
            status = Find_next(next,&search_attrib);
            }
         }      /* while */
       }
   if (status == NOMOREFILES)
      status = NOERROR;

   if (status != NOERROR) {                                           /*;AN000;*/
      }

   Dta_restore(dta_area,128);
   return(status);
}


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Check_appendx()                                  */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Check APPEND /X status.  If it is not active,                      */
/*        do nothing. If it is active, then turn it off                      */
/*        and set flag indicating that fact.                                 */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: append_active_flg                                              */
/*                                                                           */
/*    Normal exit: flag set if /X active                                     */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Check_appendx()                                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   void ctl_brk_handler();                                             /*;AN000;*/
   extern crit_err_handler();                                          /*;AN000;*/
   WORD *ptr;                                                          /*;AN000;*/

   inregs.x.ax = 0xb700;         /* Is appendx installed ? */          /*;AN000;*/
   int86(0x2f,&inregs,&outregs);                                       /*;AN000;*/
   if (outregs.h.al) {                                                 /*;AN000;*/
      inregs.x.ax = 0xb702;           /* Get version */                /*;AN000;*/
      int86(0x2f,&inregs,&outregs);                                    /*;AN000;*/
      if (outregs.x.ax == 0xffff) {                                    /*;AN000;*/
         inregs.x.ax = 0xb706;        /* Get /X status */              /*;AN000;*/
         int86(0x2f,&inregs,&outregs);                                 /*;AN000;*/
         append_x_status = outregs.x.bx;  /* save status to restore */ /*;AN000;*/

         /* turn off append /x */
         inregs.x.ax = 0xb707;        /* Set /X status */              /*;AN000;*/
         inregs.x.bx = append_x_status & INACTIVE;                     /*;AN000;*/
         int86(0x2f,&inregs,&outregs);                                 /*;AN000;*/
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/

   /* get critical error handler vector for later */
   inregs.x.ax = 0x3524;       /* get critical error vector */         /*;AN000;*/
   intdosx(&inregs,&outregs,&segregs);                                 /*;AN000;*/
   ptr = (WORD *)&old_int24_off;                                       /*;AN000;*/
   *ptr++ = (WORD)outregs.x.bx;                                        /*;AN000;*/
   *ptr = (WORD)segregs.es;                                            /*;AN000;*/

   /* set crtl-c & critical error handler vector */
   segread(&segregs);
   inregs.x.ax = 0x2523;        /* crtl-c - int 23 */                  /*;AN000;*/
   inregs.x.dx = (WORD) ctl_brk_handler;                               /*;AN000;*/
   segregs.ds = (WORD) segregs.cs;                                     /*;AN000;*/
   intdosx(&inregs,&outregs,&segregs);                                 /*;AN000;*/

   inregs.x.ax = 0x2524;        /* critical err - int 24 */            /*;AN000;*/
   inregs.x.dx = (WORD) crit_err_handler;                              /*;AN000;*/
   segregs.ds = (WORD) segregs.cs;                                     /*;AN000;*/
   intdosx(&inregs,&outregs,&segregs);                                 /*;AN000;*/
   strcpy(fix_es_reg,NUL);      /* restore ES register */              /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Reset_appendx()                                  */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Reset APPEND /X status.  If it is not active,                      */
/*        do nothing. If it is active, then turn it on                       */
/*        and set flag indicating that fact.                                 */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: append_active_flg                                              */
/*                                                                           */
/*    Normal exit: flag set if /X active                                     */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/

Reset_appendx()                                                        /*;AN000;*/
{                                                                      /*;AN000;*/
   if (append_x_status != 0)  {                                        /*;AN000;*/
      inregs.x.ax = 0xb707;                                            /*;AN000;*/
      inregs.x.bx = append_x_status;                                   /*;AN000;*/
      int86(0x2f,&inregs,&outregs);                                    /*;AN000;*/
      }                                                                /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Check_DBCS()                                     */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Given an array and a position in the array, check if the character */
/*        is a non-DBCS character.                                           */
/*                                                                           */
/*    Input:  array, character position, character                           */
/*                                                                           */
/*    Output: TRUE - if array[position-1] != DBCS character  AND             */
/*                      array[position] == character.                        */
/*            FALSE - otherwise                                              */
/*    Normal exit: none                                                      */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/
WORD Check_DBCS(array,position,character)                              /*;AN000;*/
   char *array;                                                        /*;AN000;*/
   WORD position;                                                      /*;AN000;*/
   char character;                                                     /*;AN000;*/
{                                                                      /*;AN000;*/
   BYTE far *ptr;                                                      /*;AN000;*/
   WORD i;                                                             /*;AN000;*/
   char c;                                                             /*;AN000;*/
   char darray[128];        /* DBCS array, put "D" in every position*/ /*;AN000;*/
                            /* that corresponds to the first byte   */
                            /* of a DBCS character.                 */
   for (i=0;i<128;i++)                                                 /*;AN000;*/
      darray[i] = ' ';                                                 /*;AN000;*/

   /* Check each character, starting with the first in string, for DBCS */
   /* characters and mark each with a "D" in the corresponding darray.  */
   for (i=0;i<position;i++) {                                          /*;AN000;*/
      c = array[i];                                                    /*;AN000;*/

      /* look thru DBCS table to determine if character is first byte */
      /* of a double byte character                                   */
      for (ptr=DBCS_ptr; (WORD)*(WORD far *)ptr != 0; ptr += 2) {      /*;AN000;*/

         /* check if byte is within range values of DOS DBCS table */
         if (c >= *ptr && c <= *(ptr+1)) {                             /*;AN000;*/
            darray[i] = 'D';                                           /*;AN000;*/
            i++;           /* skip over second byte of DBCS */         /*;AN000;*/
            break;
            }
         }                                                             /*;AN000;*/
      }                                                                /*;AN000;*/

   /* if character is not DBCS then check to see if it is == to character */
   if (darray[position-1] != 'D' && character == array[position]) {    /*;AN000;*/
      return (TRUE);                                                   /*;AN000;*/
      }                                                                /*;AN000;*/
   else                                                                /*;AN000;*/
      return (FALSE);                                                  /*;AN000;*/
}                                                                      /*;AN000;*/


/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Get_DBCS_vector()                                */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Gets the double-byte table vector.                                 */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit: none                                                      */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/
Get_DBCS_vector()                                                      /*;AN000;*/
{                                                                      /*;AN000;*/
    WORD *ptr;                                                         /*;AN000;*/
    WORD *buffer;                                                      /*;AN000;*/
    DWORD far *addr_ptr;                                               /*;AN000;*/

    /* allocate a buffer for DBCS table vector */
    buffer = Dallocate(5);      /* at least 5 bytes big */             /*;AN000;*/

    inregs.x.ax = 0x6507;      /* get extended country info */         /*;AN000;*/
    inregs.x.bx = -1;             /* use active code page */           /*;AN000;*/
    inregs.x.cx = 5;              /* 5 bytes of return data */         /*;AN000;*/
    inregs.x.dx = -1;             /* use default country */            /*;AN000;*/
    inregs.x.di = 0;              /* buffer offset */                  /*;AN000;*/
    segregs.es = (WORD)buffer;    /* buffer segment */                 /*;AN000;*/
    intdosx(&inregs,&outregs,&segregs);                                /*;AN000;*/
    strcpy(fix_es_reg,NUL);                                            /*;AN000;*/

    outregs.x.di++;            /* skip over id byte */                 /*;AN000;*/

    /* make a far ptr from ES:[DI] */
    addr_ptr = 0;                                                      /*;AN000;*/
    ptr = (WORD *)&addr_ptr;                                           /*;AN000;*/
    *ptr = (WORD)outregs.x.di;   /* get offset */                      /*;AN000;*/
    ptr++;                                                             /*;AN000;*/
    *ptr = (WORD)segregs.es;     /* get segment */                     /*;AN000;*/
    DBCS_ptr = (BYTE far *)*addr_ptr;                                  /*;AN000;*/
    DBCS_ptr += 2;               /* skip over table length */          /*;AN000;*/

    /* DBCS_ptr points to DBCS table */                                /*;AN000;*/
    strcpy(fix_es_reg,NUL);                                            /*;AN000;*/
}                                                                      /*;AN000;*/



/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Error_exit()                                     */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        displays an extended error message with - filename                 */
/*                                                                           */
/*    Input:  error_file_name[] must contain name of file, if needed for     */
/*            message output.                                                */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/
void Error_exit(msg_class,ext_err_num,subcnt)                          /*;AN000;*/
                                                                       /*;AN000;*/
   int msg_class;                                                      /*;AN000;*/
   int ext_err_num;                                                    /*;AN000;*/
   int subcnt;                                                         /*;AN000;*/
{                                                                      /*;AN000;*/
   segread(&segregs);                                                  /*;AN000;*/
   msg_error.sub_value_seg = segregs.ds;                               /*;AN000;*/
   msg_error.sub_value = (WORD)error_file_name;                        /*;AN000;*/
   inregs.x.ax = (WORD)ext_err_num;                                    /*;AN000;*/
   inregs.x.bx = STDERR;                                               /*;AN000;*/
   inregs.x.cx = subcnt;                                               /*;AN000;*/
   inregs.h.dh = (WORD)msg_class;                                      /*;AN000;*/
   inregs.h.dl = NOINPUT;                                              /*;AN000;*/
   inregs.x.si = (WORD)&msg_error;                                     /*;AN000;*/
   sysdispmsg(&inregs,&outregs);                                       /*;AN000;*/

   /* check for error printing message */
   if (outregs.x.cflag & CARRY) {                                      /*;AN000;*/
      outregs.x.bx = (WORD) STDERR;                                    /*;AN000;*/
      outregs.x.si = NOSUBPTR;                                         /*;AN000;*/
      outregs.x.cx = NOSUBCNT;                                         /*;AN000;*/
      outregs.h.dl = exterr_msg_class;                                 /*;AN000;*/
      sysdispmsg(&outregs,&outregs);                                   /*;AN000;*/
      }                                                                /*;AN000;*/

   Reset_appendx();             /* Reset APPEND /X status */           /*;AN000;*/
   exit(1);                                                            /*;AN000;*/
}                                                                      /*;AN000;*/



/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     Parse_err()                                      */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        displays an parser   error message with - filename                 */
/*                                                                           */
/*    Input:  error_file_name[] must contain name of file, if needed for     */
/*            message output.                                                */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/
void Parse_err(error_num)                                              /*;AN000;*/

   WORD error_num;                                                     /*;AN000;*/
{                                                                      /*;AN000;*/
   char *cptr;                                                         /*;AN000;*/
   char *sptr;                                                         /*;AN000;*/

   /* take out leading spaces, point to beginning of parameter */
   for (((int)sptr) = inregs.x.si; ((int)sptr) < outregs.x.si && *sptr == BLANK; sptr++)  /*;AN000;*/
      /* null statement */ ;                                           /*;AN000;*/

   /* find end of this parameter in command line and put end-of-string there */
   for (cptr = sptr; ((int)cptr) < outregs.x.si && *cptr != BLANK; cptr++)    /*;AN000;*/
      /* null statement */ ;                                           /*;AN000;*/
   *cptr = NUL;                                                        /*;AN000;*/
   strcpy(error_file_name,sptr);                                       /*;AN000;*/

   /* check for messages with no parameter */
   if (error_num == p_op_missing)                                      /*;AN000;*/
      Error_exit(ERR_PARSE,error_num,NOSUBCNT);                        /*;AN000;*/
   else                                                                /*;AN000;*/
      Error_exit(ERR_PARSE,error_num,ONEPARM);                         /*;AN000;*/
}                                                                      /*;AN000;*/




/*���������������������������������������������������������������������������*/
/*                                                                           */
/*     Subroutine Name:     ctl_brk_handler                                  */
/*                                                                           */
/*     Subroutine Function:                                                  */
/*        Crtl-break interrupt handler.                                      */
/*                                                                           */
/*    Input:  none                                                           */
/*                                                                           */
/*    Output: none                                                           */
/*                                                                           */
/*    Normal exit:                                                           */
/*                                                                           */
/*    Error exit: None                                                       */
/*                                                                           */
/*    Internal References:                                                   */
/*              None                                                         */
/*                                                                           */
/*    External References:                                                   */
/*              None                                                         */
/*                                                                           */
/*���������������������������������������������������������������������������*/
void ctl_brk_handler()
{
   Reset_appendx();
   exit(3);                                                            /*;AN000;*/
/* inregs.x.ax = 0x4c03;     /* DOS terminate int call */              /*;AN000;*/
/* intdos(&inregs,&outregs);                                           /*;AN000;*/
}