;       SCCSID = @(#)demparse.asm       6.3 91/10/13
;       SCCSID = @(#)demparse.asm       6.3 91/10/13
;       SCCSID = @(#)demparse.asm       6.3 91/10/13
;
;   Revisions:
;
;Local  DCR/
;Tag    PTM(R)  Who     When/What
;               danno   03-Mar-1989
;                       Created for MVDM
;
; B001  10/9/91  CP20 AA04213  Mark Rogalski
;       parse fcb should always return successful so that mapped drives
;       can have FCBs set up for them correctly.
; 77986 02/11/94 ChangeTeam  - Changed $Parse_File_Descriptor to not
;       alter AL when AL=1, so XCOPY to "*.*" will complete successfully.
; 90144 08/17/94 ChangeTeam - Changed $Parse_File_Descriptor to check
;       if drive associated with parse is a DOS or OS/2 drive.
;       OS/2 places a signature fefe for last two bytes of extension
;       for Dir *. command.  VMB with DOS LS 4.0 found this problem.
; 90145 08/24/94 ChangeTeam  - Changed $Parse_File_Descriptor to not
;       alter AL when AL=ff, so invalid drive specification will be reported.
;107573 12/20/94 Change Team - Added check in $Parse_file_Descriptor
;       to determine if the drive is mapped, if not return AL=ff .;107573                      
;       The whole logic of this routine has been rewritten        ;107573   
.xlist
include v86seg.inc

.xcref
include basemaca.inc
include osmaca.inc
include oldmaca.inc
include demmac.inc
include mvdmexp.inc
include demsvc.inc
include dossymc.inc
.cref
.list
        CpuMode 386

V86CODE SEGMENT
        ASSUME  CS:V86GROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING

        EXTRN      Get_User_Stack:NEAR
        EXTRN      os2_handled:BYTE         ;BC001
        EXTRN      VMcheck_drive:NEAR       ;90144
        EXTRN       check_map:NEAR          ;107573
        EXTRN       check_dos:NEAR          ;107573   

BREAK <$Parse_File_Descriptor -- Parse an arbitrary string into an FCB>

; Inputs:
;       DS:SI Points to a command line
;       ES:DI Points to an empty FCB
;       Bit 0 of AL = 1 At most one leading separator scanned off
;                   = 0 Parse stops if separator encountered
;       Bit 1 of AL = 1 If drive field blank in command line - leave FCB
;                   = 0  "    "    "     "         "      "  - put 0 in FCB
;       Bit 2 of AL = 1 If filename field blank - leave FCB
;                   = 0  "       "      "       - put blanks in FCB
;       Bit 3 of AL = 1 If extension field blank - leave FCB
;                   = 0  "       "      "        - put blanks in FCB
; Function:
;       Parse command line into FCB
; Returns:
;       AL = 1 if '*' or '?' in filename or extension, 0 otherwise
;       AL = ff if invalid drive            90145
;       DS:SI points to first character after filename

        procedure   $PARSE_FILE_DESCRIPTOR,NEAR
ASSUME  DS:NOTHING,ES:NOTHING

           SVC    SVC_DEMMAKEFCB              ;107573                         
           push     ax                        ;107573
           mov      al, byte ptr es:[di]      ;90144 get drive # from FCB  ;107573   
           call     check_map                 ;See if it is a Mapped drive      ;107573          
           jc       CkDOS                     ;if not mapped check for DOS drive      ;107573   
           pop      ax                        ;107573
           cmp      ax,1                      ;77986    ;107573   
           jz       SetReturn                 ;107573   
           xor      al,al                     ;Mapped drive give good rc   ;107573   
           jmp      SetReturn                 ;107573   
CkDos:                                        ;107573
           mov      al,byte ptr es:[di]       ;107573   
           call     check_dos                 ;check if dos drive ;107573   
           pop      ax                        ;carry ==> DOS does not want it         ;107573   
           jc       SetReturn                ;return whatever OS/2 had returned        ;107573    
                                              ;else let Dos Handle the call ;107573   
           mov      cs:os2_handled,0          ;107573   
           ret                                ;107573   
SetReturn:                                    ;107573   
           mov      cs:os2_handled,1          ;107573   
           PUSH     SI                        ;107573   
           invoke   get_user_stack            ;107573   
           POP      [SI.user_SI]              ;107573   
                  
parse1:  
           return                             ;77986   ;107573   

;        SVC     SVC_DEMMAKEFCB
;        mov     dl, byte ptr es:[di]   ;90144 get drive number from FCB
;        call    VMcheck_drive          ;90144 return if OS/2 drive
;        PUSH    SI
;        invoke  get_user_stack
;        POP     [SI.user_SI]
;        cmp     al,01                  ; if al = 1,                   77986
;        je      parse1                 ;    do not zero it.           77986
;        cmp     al,0ffh                ; if al = ff,                  90145
;        je      parse1                 ;    do not zero it.           90145
;        xor     al,al                  ; always return successful (for mapping) ;BN001
;parse1: return                         ;                              77986

EndProc $PARSE_FILE_DESCRIPTOR


V86CODE ENDS
        END
