forked from DigitalMars/optlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.d
1230 lines (1036 loc) · 22.1 KB
/
parse.d
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
module parse;
import io_struc;
// MVFILNAM - Copyright (c) SLR Systems 1994
void* MOVE_FILE_LIST_GINDEX_PATH_PRIM_EXT(EAX, ECX)
{
// ECX IS GINDEX, EAX IS DESTINATION
EDI = EAX;
FILE_LIST_STRUCT* EDX;
CONVERT EDX,ECX,FILE_LIST_GARRAY
EAX = [EDX].FILE_LIST_PATH_GINDEX;
if (EAX)
{
CONVERT EAX,EAX,FILE_LIST_GARRAY
ASSUME EAX:PTR FILE_LIST_STRUCT
ECX = EAX.FILE_LIST_NFN.NFN_PATHLEN;
ESI = &EAX.FILE_LIST_NFN.NFN_TEXT;
memcpy(EDI, ESI, ECX);
EDI += ECX;
}
// OUTPUT FILENAME IN ASCII PLEASE
// FROM [SI] TO [DI]
ECX = [EDX].FILE_LIST_NFN.NFN_TOTAL_LENGTH;
ESI = &[EDX].FILE_LIST_NFN.NFN_TEXT;
memcpy(EDI, ESI, ECX);
return EDI + ECX;
}
ubyte* MOVE_PATH_PRIM_EXT(ubyte* EAX, NFN_STRUCT* ECX)
{
// OUTPUT FILENAME IN ASCII PLEASE
// FROM [ECX] TO [EAX]
memcpy(EAX, &ECX.NFN_TEXT, ECX.NFN_TOTAL_LENGTH);
return EAX + ECX.NFN_TOTAL_LENGTH;
}
// MVFNASC - Copyright (c) SLR Systems 1994
void MOVE_FN_TO_ASCIZ(NFN_STRUCT* EAX)
{
// MOVE FILNAM [EAX] TO ASCIZ STRING
auto ECX = EAX.NFN_TOTAL_LENGTH;
ASCIZ_LEN = ECX; // length in bytes, not 0
memcpy(&ASCIZ, EAX.NFN_TEXT, ECX);
*cast(int*)(&ASCIZ + ECX) = 0;
}
// MVFN - Copyright (c) SLR Systems 1994
MOVE_NFN(NFN_STRUCT* EAX, NFN_STRUCT* ECX)
{
// EAX IS TARGET NFN_STRUCT, ECX IS SOURCE
memcpy(EAX, ECX,
NFN_STRUCT.sizeof - NFN_TEXT_SIZE + ECX.NFN_TOTAL_LENGTH + 4);
}
// MVLISTNF - Copyright (c) SLR Systems 1994
MOVE_FILE_LIST_GINDEX_NFN(NFN_STRUCT* EAX, ECX)
{
// MOVE COMPLETE NFN FROM FILE LIST TO NFN STRUCTURE
// ECX IS FILE_LIST_GINDEX
EDX = EAX;
CONVERT EAX,ECX,FILE_LIST_GARRAY
ECX = [EAX].FILE_LIST_STRUCT.FILE_LIST_NFN.NFN_TOTAL_LENGTH +
NFN_STRUCT.NFN_TEXT+4;
EAX = [EAX].FILE_LIST_STRUCT.FILE_LIST_PATH_GINDEX;
memcpy(EDX, &FILE_LIST_STRUCT.FILE_LIST_NFN[EAX], ECX);
if (EAX)
{
CONVERT EAX,EAX,FILE_LIST_GARRAY
ECX = &FILE_LIST_STRUCT.FILE_LIST_NFN[EAX];
EAX = EDX;
MOVE_ECXPATH_EAX();
}
}
// MVPATH
MOVE_ECXPATH_EAX(NFN_STRUCT* EAX, NFN_STRUCT* ECX)
{
// MOVE PATH FROM ECX TO EAX, PRESERVE EAX
auto dst = EAX;
auto src = ECX;
// Make room
memmove(&dst.NFN_TEXT[src.NFN_PATHLEN],
&dst.NFN_TEXT[dst.NFN_PATHLEN],
dst.NFN_TOTAL_LENGTH - dst.NFN_PATHLEN);
// Copy path
memcpy(dst.NFN_TEXT, src.NFN_TEXT, src.NFN_PATHLEN);
dst.NFN_TOTAL_LENGTH += src.NFN_PATHLEN - dst.NFN_PATHLEN;
dst.NFN_PATHLEN = src.NFN_PATHLEN;
*cast(int*)&dst.NFN_TEXT[dst.NFN_TOTAL_LENGTH] = 0;
return dst;
}
// MVSRCFIL - Copyright (c) SLR Systems 1994
MOVE_SRCPRIM_TO_EAX_CLEAN(NFN_STRUCT* EAX)
{
EAX.NFN_PRIMLEN = 0;
EAX.NFN_PATHLEN = 0;
EAX.NFN_EXTLEN = 0;
EAX.NFN_TOTAL_LENGTH = 0;
MOVE_SRCPRIM_TO_EAX(EAX);
}
MOVE_SRCPRIM_TO_EAX(NFN_STRUCT* EAX)
{
// MOVE PRIMARY PART OF SRCNAM TO FILNAM
MOVE_ECXPRIM_TO_EAX(EAX, &SRCNAM);
}
MOVE_ECXPRIM_TO_EAX(NFN_STRUCT* EAX, NFN_STRUCT* ECX)
{
auto dst = EAX;
auto src = ECX;
// Make room
memmove(&dst.NFN_TEXT[dst.NFN_PATHLEN + src.NFN_PRIMLEN],
&dst.NFN_TEXT[dst.NFN_PATHLEN + dst.NFN_PRIMLEN],
dst.NFN_EXT);
// Copy path
memcpy(&dst.NFN_TEXT[dst.NFN_PATHLEN],
&src.NFN_TEXT[src.NFN_PATHLEN],
src.NFN_PRIMLEN);
dst.NFN_TOTAL_LENGTH += src.NFN_PRIMLEN - dst.NFN_PRIMLEN;
dst.NFN_PRIMLEN = src.NFN_PRIMLEN;
*cast(int*)&dst.NFN_TEXT[dst.NFN_TOTAL_LENGTH] = 0;
return dst;
}
// GTNXTU - Copyright (c) SLR Systems 1994
// Get next character from EBX in upper case
ubyte GTNXTU(inout ubyte* EBX)
{
auto AL = *EBX++;
if (AL >= 'a' && AL <= 'z')
AL -= 0x20;
return AL;
}
// DO_FN - Copyright (c) SLR Systems 1994
DO_FILENAME(NFN_STRUCT* ECX, CMDLINE_STRUCT* EAX)
{
// EAX IS FILESTUFF_PTR
PARSE_FILENAME(ECX);
// DEAL WITH DEFAULTS
return DO_DEFAULTS(ECX, EAX);
}
DO_DEFAULTS(NFN_STRUCT* ECX, CMDLINE_STRUCT* EAX)
{
// EAX IS FILESTUFF_PTR
// ECX IS NFN_STRUCT
NFN_STRUCT* ESI = ECX;
CMDLINE_STRUCT* EDI = EAX;
AL = ESI.NFN_FLAGS;
if (EAX & MASK NFN_PRIM_SPECIFIED)
JZ L1$
L19$:
if (EAX & MASK NFN_EXT_SPECIFIED)
JNZ L3$
// MOVE DEFAULT EXTENT (UNLESS PRIMARY IS NUL)
EAX = ESI;
if (!CHECK_NUL1(EAX))
{
// MOVE DEFAULT EXTENT...
EAX = 0;
AL = EDI.CMD_EXTENT[0];
ECX = EAX;
EAX -= ESI.NFN_EXTLEN;
ESI.NFN_EXTLEN = ECX;
ESI.NFN_TOTAL_LENGTH += EAX;
EAX = ESI.NFN_PATHLEN + ESI.NFN_PRIMLEN;
memcpy(ESI.NFN_TEXT + EAX, EDI.CMD_EXT + 1, ECX);
*cast(int*)(ESI.NFN_TEXT + EAX + ECX) = 0;
}
L3$:
EAX = ESI;
return EAX;
L1$:
// NO PRIMARY FILENAME, MOVE EITHER NUL OR SRC...
PUSH EAX
[EDI].CMD_SELECTED();
// WANT IT, MOVE SOURCE NAME
JNZ L13$
// OK, IF PATH OR EXTENTION SPECIFIED, MOVE SOURCE TOO
if (BPTR [ESI].NFN_FLAGS & MASK NFN_PATH_SPECIFIED+MASK NFN_EXT_SPECIFIED)
JZ L15$
L13$:
EAX = ESI;
MOVE_SRCPRIM_TO_EAX();
L15$:
POP EAX
goto L19$;
}
// CHKNUL - Copyright (c) SLR Systems 1994
CHECK_NUL(NFN_STRUCT* EAX)
{
// SEE IF [EAX] IS NUL DEVICE..., SET FLAG IF SO...
if (EAX.NFN_PRIMLEN == 0 || !CHECK_NUL1(EAX))
EAX.NFN_FLAGS |= MASK NFN_NUL;
}
// Return true if [EAX] primary name is 'NUL'
bool CHECK_NUL1(NFN_STRUCT* EAX)
{
// SEE IF [EAX] PRIMARY NAME IS 'NUL'
// RETURNS EAX INTACT
EDX = [EAX].NFN_PRIMLEN;
ECX = [EAX].NFN_PATHLEN;
if (EDX != 3)
return false;
ECX = &EAX.NFN_TEXT[ECX+1];
AL = ECX[-1];
AL = toupper(AL);
if (AL != 'N')
return false;
AL = *ECX++;
AL = toupper(AL);
if (AL != 'U')
return false;
AL = *ECX++;
AL = toupper(AL);
if (AL != 'L')
return false;
return true;
}
// LIBRTN - Copyright (c) SLR Systems 1994
struct LRF_VARS
{
ubyte[NFN_STRUCT.sizeof] LRF_NFN_STRUCT_EBP;
}
FIX MACRO XX
XX EQU ([EBP-SIZEOF LRF_VARS].(XX&_EBP))
ENDM
FIX LRF_NFN_STRUCT
ubyte* LIB_ROUTINE_FINAL(EAX)
{
// EAX IS INPTR1 TO USE
LRF_VARS LRF_NFN_STRUCT;
EDX = EAX;
while (1)
{
do
{
AL = *EDX++;
} while (AL == ';' || AL == ',' || AL == ' ');
if (AL == CR)
break;
--EDX;
if (AL == 0x1A)
break;
ECX = &LRF_NFN_STRUCT;
EAX = &LIBSTUFF;
// EAX IS FILESTUFF
// EDX IS INPTR
// ECX IS NFN_STRUCT, RETURNS EAX IS INPTR
GET_FILENAME();
PUSH EAX
EAX = &LRF_NFN_STRUCT;
HANDLE_LIBS();
POP EDX
}
return EDX;
}
LIB_ROUTINE_FINAL_COMENT()
{
// EAX IS INPTR1 TO USE
LRF_VARS LRF_NFN_STRUCT;
EDX = EAX;
goto L2$;
L1$:
ECX = &LRF_NFN_STRUCT;
EAX = &LIBSTUFF;
// EAX IS FILESTUFF, EDX IS INPTR, ECX IS NFN_STRUCT, RETURNS EAX IS INPTR
GET_FILENAME();
PUSH EAX
EAX = &LRF_NFN_STRUCT;
ASSUME EAX:PTR NFN_STRUCT
ECX = EAX.NFN_PATHLEN + EAX.NFN_PRIMLEN;
EDX = EAX.NFN_EXTLEN;
if (EDX == 4)
{
DL = [EAX+ECX+1].NFN_TEXT;
ECX = &[EAX+ECX+2].NFN_TEXT;
if (toupper(DL) == 'L' &&
toupper(*ECX++) == 'O' &&
toupper(*ECX++) == 'D')
{
// HANDLE LIKE A STUB FILE
if (LOD_SUPPLIED)
{
WARN_RET(DUP_LOD_ERR);
}
else
{
AL = DOSX_EXE_TYPE;
XCHG AL,EXETYPE_FLAG
if (AL && AL != DOSX_EXE_TYPE)
ERR_RET(DOSX_NONDOSX_ERR);
if (EXEPACK_SELECTED)
ERR_ABORT(DOSX_EXEPACK_ERR);
EAX = &LRF_NFN_STRUCT;
LOD_SUPPLIED = -1;
HANDLE_LOD();
}
POP EDX
goto L9$;
}
}
// IGNORE LIBSEARCH REQUESTS?
if (DEFAULTLIBRARYSEARCH_FLAG)
{
EAX = &LRF_NFN_STRUCT;
HANDLE_LIBS();
}
POP EDX
goto L2$;
L2$:
do
{
AL = *EDX++;
} while (AL == ';' || AL == ',' || AL == ' ');
if (AL != CR)
{
--EDX;
if (AL != 0x1A)
goto L1$;
}
L9$:
return EDX;
}
ALIGN 4
LIBSTUFF LABEL DWORD
DCA RET_FALSE; // DEFAULT TO NUL
DD LIB_EXT; // DEFAULT LIB EXTENSION
version(fg_mscmd)
{
DCA RET_TRUE; // YES, THIS IS WANTED
DD LIB_MSG; // IF PROMPTING...
LIB_MSG DB 21,'Libraries and Paths: '
}
LIB_EXT DB 4,'.lib'
RET_FALSE()
{
if (AL $$ AL)
return;
}
RET_TRUE()
{
AL |= 1;
return;
}
// GET_FN - Copyright (c) SLR Systems 1994
GET_FILENAME(EAX, NFN_STRUCT* ECX, EDX)
{
// EAX IS FILESTUFF_PTR
// ECX IS NFN_STRUCT TO USE
// EDX IS INPTR1 OR SOMETHING
// RETURNS:
// EAX IS UPDATED INPTR1
PUSHM EDI,ESI
ESI = EDX;
PUSH EBX
EBX = EAX;
L0$:
AL = *ESI++;
if (AL == ' ')
goto L0$;
if (AL == 9)
goto L0$;
--ESI;
EDI = &[ECX].NFN_TEXT;
EAX = 0;
L1$:
AL = *ESI++;
if (AL == '"')
goto L6$;
*EDI++ = AL;
AL = FNTBL[EAX];
if (AL & MASK FNTBL_ILLEGAL)
JZ L1$
L15$:
// MOV DPTR [EDI-2],0
EDI -= ECX;
--ESI;
EDI -= NFN_STRUCT.NFN_TEXT+1;
[ECX].NFN_TOTAL_LENGTH = EDI;
JZ L9$
EAX = EBX;
// EAX IS FILESTUFF_PTR, ECX IS NFN_STRUCT
DO_FILENAME();
L5$:
POP EBX
EAX = ESI;
POPM ESI,EDI
return;
L6$:
AL = *ESI++;
if (AL == '"')
goto L1$;
*EDI++ = AL;
if (AL == ' ')
goto L6$;
AL = FNTBL[EAX];
if (AL & MASK FNTBL_ILLEGAL)
JZ L6$
goto L15$;
L9$:
ERR_INBUF_ABORT(FILE_EXP_ERR);
goto L5$;
}
// HNDLLIBS - Copyright (c) SLR Systems 1994
HANDLE_LIBS(NFN_STRUCT* EAX)
{
if (EAX.NFN_FLAGS & MASK NFN_PRIM_SPECIFIED+MASK NFN_EXT_SPECIFIED)
{
DO_SEARCH_LIBRARY(EAX);
return;
}
// Remove base file name and extension from NFN_TEXT
EAX.NFN_TOTAL_LENGTH -= EAX.NFN_PRIMLEN + EAX.NFN_EXTLEN;
EAX.NFN_PRIMLEN = 0;
EAX.NFN_EXTLEN = 0;
*cast(int*)&EAX.NFN_TEXT[EAX.NFN_TOTAL_LENGTH] = 0;
STORE_LIBPATH(EAX);
}
DO_SRCNAM(NFN_STRUCT* EAX)
{
MOVE_NFN(&SRCNAM, EAX);
}
DO_LIBRARY(NFN_STRUCT* EAX)
{
DO_SEARCH_LIBRARY(EAX);
}
DO_SEARCH_LIBRARY(NFN_STRUCT* EAX)
{
EAX.NFN_TYPE = NFN_LIB_TTYPE;
DO_OBJS_1(EAX, &LIB_LIST);
}
DO_OBJS(NFN_STRUCT* EAX)
{
// IF NOT NUL, ADD NEW TO LIST...
DO_OBJS_1(EAX, &OBJ_LIST);
}
DO_OBJS_1(NFN_STRUCT* EAX, ECX)
{
// ECX IS FILE_LIST TO PUT IT IN
DH = [EAX].NFN_FLAGS;
DL = 0;
DH &= MASK NFN_AMBIGUOUS;
if (!DH)
{
// CURRENTLY UNAMBIGUOUS
RESS THIS_AMBIGUOUS,DL
NOT_AMBIGUOUS();
return;
}
// OK, NAME IN SI IS AMBIGUOUS...
PUSHM EDI,ESI
--EDX; // LISTTYPE
EDI = ECX; // NOPE, GOT WHOLE FILENAME
ESI = EAX;
// OOPS...
THIS_AMBIGUOUS,DL = -1;
// EAX IS NFN_STRUCT
DO_FINDFIRST();
// ALL DONE, NOT FOUND...
JC L11$
L1$:
EAX = ESI;
ECX = EDI;
NOT_AMBIGUOUS();
EAX = ESI;
DO_FINDNEXT();
JNC L1$
CLOSE_FINDNEXT();
L11$:
POPM ESI,EDI
return;
}
COPY_FIRST_OBJ(EDI)
{
if (EDI == &OBJ_LIST)
{ DO_SRCNAM();
EAX = ESI;
}
COPY_FIRST_OBJ_RET();
}
NOT_AMBIGUOUS(NFN_STRUCT* EAX, ECX)
{
// ECX IS FILE_LIST
EDX = SRCNAM.NFN_PRIMLEN;
EDI = ECX;
ESI = EAX;
if (!EDX && EDI == &OBJ_LIST)
{ DO_SRCNAM();
EAX = ESI;
}
COPY_FIRST_OBJ_RET();
}
COPY_FIRST_OBJ_RET()
{
// RETURNS ECX AS SYMBOL ADDRESS
FILENAME_INSTALL();
// EAX IS GINDEX
ASSUME ECX:PTR FILE_LIST_STRUCT
EDX = EAX;
// ADD TO LIST IF NOT ALREADY THERE...
// DS:BX IS SYMBOL, DX IS LOGICAL ADDR
PUSH EBX
AL = ECX.FILE_LIST_FLAGS;
if (DOING_NODEF)
{
ECX.FILE_LIST_FLAGS |= MASK MOD_IGNORE;
return;
}
// MODEFAULT, IGNORE
if (EAX & MASK MOD_IGNORE)
return;
if (EAX & MASK MOD_ADD)
// ALREADY IN ADD LIST...
{
ASSUME EDI:PTR FILE_LISTS
// ALREADY THERE, WAS IT UNAMBIGUOUS?
if (EAX & MASK MOD_UNAMBIG)
return; // YES, IGNORE.
// WAS AMBIGUOUS, WHAT ABOUT NOW?
if (THIS_AMBIGUOUS)
return; // STILL AMBIGUOUS
// NOW UNAMBIGUOUS, MOVE IT TO END OF LINKED LIST...
ECX.FILE_LIST_FLAGS = AL |MASK MOD_UNAMBIG;
// FIRST, IF .FILE_LAST_ITEM MATCHES, SKIP SEARCH, JUST FLAG IT..
if ([EDI].FILE_LAST_GINDEX == EDX)
return;
// SEARCH LIST FOR IT (DX:BX)
PUSH EDI
EAX = [EDI].FILE_FIRST_GINDEX;
do
{
CONVERT EDI,EAX,FILE_LIST_GARRAY
ASSUME EDI:PTR FILE_LIST_STRUCT
EAX = [EDI].FILE_LIST_NEXT_GINDEX;
} while (EAX != EDX);
// MAKE [DI:CX] POINT TO [DS:SI]
EAX = 0;
EBX = [ECX].FILE_LIST_NEXT_GINDEX;
[ECX].FILE_LIST_NEXT_GINDEX = 0;
[EDI].FILE_LIST_NEXT_GINDEX = EBX;
POP EDI
// NOW, MAKE .LAST PT TO THIS...
}
else
{
AL |= MASK MOD_ADD;
if (THIS_AMBIGUOUS == 0)
{
version(any_overlays)
{
if (EAX & MASK MOD_UNAMBIG && ECX.FILE_LIST_SECTION_GINDEX)
{
ERR_INBUF_ABORT(DUP_SECTION_ERR);
}
}
AL |= MASK MOD_UNAMBIG;
}
[ECX].FILE_LIST_FLAGS = AL;
}
// PUT_IN_ADD_LIST
// ESI IS NFN_STRUCT
// EDI IS LISTTYPE
// EDX IS CURN FILE_LIST_GINDEX
// ECX IS CURN FILE_LIST_ADDRESS
ASSUME EDI:PTR FILE_LISTS
version(any_overlays)
{
ECX.FILE_LIST_SECTION = CURN_SECTION;
ECX.FILE_LIST_PLTYPE = CURN_PLTYPE;
}
EAX = EDI.FILE_LAST_GINDEX;
ECX.FILE_LIST_PLINK_FLAGS |= DEBUG_TYPES_SELECTED;
EDI.FILE_LAST_GINDEX = EDX;
CONVERT EAX,EAX,FILE_LIST_GARRAY
ASSUME EAX:PTR FILE_LIST_STRUCT
// CAUSE THIS IS NOT THREAD
EAX.FILE_LIST_NEXT_GINDEX = EDX; // ORDER, THIS IS LOGICAL ORDER
version(fgh_inthreads)
{
if (HOST_THREADED & OBJS_DONE)
{
EAX = EDX;
OBJ_LIST.FILE_LAST_GINDEX = EAX;
LINK_TO_THREAD();
}
}
}
STORE_LIBPATH(NFN_STRUCT* EAX)
{
DL = 2;
ECX = OFF LIBPATH_LIST;
LNI_PATHS(EAX, EDX, ECX);
}
LNI_PATHS(NFN_STRUCT* EAX, EDX, ECX)
{
// DONT ADD NUL PATH
DH = 0;
if (EAX.NFN_PATHLEN == 0)
{
LNI_FILES(EAX, EDX, ECX);
}
}
LNI_FILES(EAX, EDX, ECX)
{
EAX.NFN_TYPE = DH;
*FILE_HASH_MOD = DL;
DO_OBJS_1();
EAX = 0;
FILE_HASH_MOD = 0;
}
HANDLE_OBJPATHS(NFN_STRUCT* EAX)
{
DL = 3;
LNI_PATHS(EAX, EDX, &OBJPATH_LIST);
}
version(fg_segm OR fg_pe)
{
HANDLE_STUBPATHS(NFN_STRUCT* EAX)
{
// PARSING PATH= VARIABLE
DL = 4;
LNI_PATHS(EAX, EDX, &STUBPATH_LIST);
}
HANDLE_STUB(NFN_STRUCT* EAX)
{
EDX = 5+256*NFN_STUB_TTYPE;
LNI_FILES(EAX, EDX, &STUB_LIST);
}
HANDLE_OLD(NFN_STRUCT* EAX)
{
EDX = 6+256*NFN_OLD_TTYPE;
LNI_FILES(EAX, EDX, &OLD_LIST);
}
HANDLE_RCS(NFN_STRUCT* EAX)
{
ECX = *cast(int*)&EAX.NFN_TEXT[EAX.NFN_PATHLEN + EAX.NFN_PRIMLEN];
if (ECX != 'SER.' && ECX != 'ser.')
WARN_ASCIZ_RET(IMPROBABLE_RES_ERR, EAX.NFN_TEXT);
EDX = 7+NFN_RES_TTYPE*256;
LNI_FILES(EAX, EDX, &RC_LIST);
}
HANDLE_LOD(NFN_STRUCT* EAX)
{
EDX = 8+NFN_LOD_TTYPE*256;
LNI_FILES(EAX, EDX, &LOD_LIST);
}
}
// PARSE_FN - Copyright (c) SLR Systems 1994
NFN_STRUCT* PARSE_FILENAME(NFN_STRUCT* EAX)
{
// EAX IS NFN_STRUCT
// (LENGTH IS ALREADY SET, AND TEXT IS THERE)
// RETURNS:
// EAX IS NFN_STRUCT
NFN_STRUCT* ESI = EAX;
EAX = 0;
NFN_STRUCT* EDI = ESI;
ESI.NFN_PATHLEN = 0;
ESI.NFN_PRIMLEN = 0;
ESI.NFN_EXTLEN = 0;
ESI.NFN_FLAGS = 0;
ESI.NFN_TYPE = 0;
ESI.reserved1 = 0;
ECX = [ESI].NFN_TOTAL_LENGTH;
ESI = &ESI.NFN_TEXT;
EDX = ESI; // SAVE START OF FILENAME IN DX
DPTR [ESI+ECX] = EAX; // ZERO AT END
ESI += ECX-1; // ESI IS AT THE LAST CHAR OF TOKEN
// SCAN FORWARDS LOOKING FOR AMBIGUOUS CHARACTERS
if (!ECX)
goto L9$
// OK, NOW SCAN BACKWARDS FOR EXTENT OR PATH STUFF
// SKIP TRAILING SPACES
L30$:
AL = *ESI--;
if (AL != ' ')
goto L31$;
--ECX;
[EDI].NFN_TOTAL_LENGTH = ECX;
if (ECX)
goto L30$
goto L9$;
L3$:
--ESI;
L31$:
AL = FNTBL[EAX];
--ECX;
if (AL & MASK FNTBL_AMBIGUOUS)
{
[EDI].NFN_FLAGS |= MASK NFN_AMBIGUOUS;
AL = [ESI];
if (ECX)
goto L3$
goto DO_PRIMARY2;
}
if (!(AL & (MASK FNTBL_PATH_SEPARATOR | MASK FNTBL_DOT)))
{
AL = *ESI;
if (ECX)
goto L3$
goto DO_PRIMARY2;
}
if (AL & MASK FNTBL_DOT)
{
// GOT A '.', SO STORE EXTENSION LENGTH
EAX = [EDI].NFN_TOTAL_LENGTH;
[EDI].NFN_FLAGS |= MASK NFN_EXT_SPECIFIED;
EAX -= ECX;
if (EAX == 1 && !FORCE_PATH)
{
// JUST A DOT, REMOVE IT...
--EDI.NFN_TOTAL_LENGTH;
}
else
{
EDI.NFN_EXTLEN = EAX;
}
// NOW LOOK ONLY FOR END-OF-PRIMARY...
EAX = 0;
if (!ECX)
goto L9$;
while (1)
{
AL = *ESI--;
AL = FNTBL[EAX];
--ECX;
if (ECX == 0)
{
if (AL & (MASK FNTBL_PATH_SEPARATOR | MASK FNTBL_AMBIGUOUS))
{
if (!(AL & MASK FNTBL_PATH_SEPARATOR))
EDI.NFN_FLAGS |= MASK NFN_AMBIGUOUS;
break;
}
goto DO_PRIMARY2;
}
if (AL & MASK FNTBL_PATH_SEPARATOR)
break;
if (AL & MASK FNTBL_AMBIGUOUS)
[EDI].NFN_FLAGS |= MASK NFN_AMBIGUOUS;
}
}
++ECX;
DO_PRIMARY:
++ESI;
DO_PRIMARY2:
EAX = EDI.NFN_TOTAL_LENGTH - EDI.NFN_EXTLEN - ECX;
EDI.NFN_PRIMLEN = EAX;
if (EAX)
[EDI].NFN_FLAGS |= MASK NFN_PRIM_SPECIFIED;
// NOW, CX IS # OF BYTES IN A PATH-SPEC
if (ECX)
{
EDI.NFN_PATHLEN = ECX;
EDI.NFN_FLAGS |= MASK NFN_PATH_SPECIFIED;
}
L9$:
// ALL DONE, CONGRATS!
if (FORCE_PATH)
{
// IF PRIMLEN OR EXTLEN !=0, MAKE THEM ZERO AND ADD A \ AT END
EBX = EDI.NFN_PRIMLEN;
EDI.NFN_FLAGS &= ~(NFN_RECORD.NFN_PRIM_SPECIFIED | NFN_RECORD.NFN_EXT_SPECIFIED);
EBX += EDI.NFN_EXTLEN;
if (EBX)
{
++EBX;
EAX = 0;
EBX += EDI.NFN_PATHLEN;
EDI.NFN_PRIMLEN = 0;
EDI.NFN_PATHLEN = EBX;
EDI.NFN_EXTLEN = 0;
EDI.NFN_TEXT[EBX-1] = '\';
++EDI.NFN_TOTAL_LENGTH;
EDI.NFN_FLAGS |= NFN_RECORD.NFN_PATH_SPECIFIED;
}
}
EAX = EDI;
return EAX;
}
// MUST BE IN DATA SEGMENT, AS WE MODIFY IT...
ubyte[256] FNTBL =
{
// ILLEGAL HPFS FILENAME CHARS ARE:
// 0-1FH, " * + , / : ; < = > ? [ \ ] |
// WE ALLOW PATH SEPARATORS \ / :
// WE ALLOW AMBIGUOUS CHARS ? *
// 00 NUL
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 01 SOH
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 02
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 03
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 04
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 05
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 06
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 07 BEL
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 08 BS
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 09 TAB
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 0A LF
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 0B
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 0C
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 0D CR
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 0E
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 0F
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 10
FNTBL_RECORD.FNTBL_ILLEGAL | FNTBL_RECORD.SYMTBL_ILLEGAL,
// 11