NEW
  AUTO 3,1
*--------------------------------------
CIFS.ChTyp
CIFS2.ChTyp
*--------------------------------------
CIFS.ChMod
CIFS2.ChMod
*--------------------------------------
CIFS.FStat
*--------------------------------------
CIFS2.FStat		lda #MLI.E.BADCALL
				sec
				rts
*--------------------------------------
CIFS.Stat		>STYA pPath				resolved path

				jsr ClearSocket
				jsr MakeTrans2Reg

				ldx #0

.1				lda SMB.QueryPathInfo,x
				sta (ZPReqPtr),y
				iny
				inx
				cpx #SMB.QueryPathInfo.Len
				bne .1

				jsr AppendPath

				lda #0
				sta (ZPReqPtr),y
				iny

				jsr SetT2ReqLenYA

				pha
				>PUSHB MountTable+3		hSocket
				>PUSHW ZPReqPtr
				
				pla
				>PUSHYA

				ldx #LIBTCPIP.Send
			jsr GO.LIBTCPIP
				bcs .9

				jmp Sleep

.9				>RET 4
*--------------------------------------
CIFS2.Stat		jsr ReadSocket
				bcs .9

				jsr GetRespData

				ldy #S.NETBIOS+S.SMB.H.STATUS
				lda (ZPRespPtr),y
				beq .1

				lda #MLI.E.FNOTFND
				bra .99

.1				>PULLW ZPPtr2			Stat Buffer

				inc pStack				Skip Filename
				inc pStack

				jsr GetRespDataOffset
				jsr FileInfo2StatBuf
				jsr StatBuf2Ptr2

				lda hResp
				>SYSCALL2 FreeMem
	
				stz CIFS.Status
				clc
				rts

.9				cmp #E.NODATA
				bne .9

				dec CIFS.Retries
				beq .90

				lda #0
				sec
				rts

.90				lda #MLI.E.IO

.99				sec
				stz CIFS.Status
				>RET 4
*--------------------------------------
CIFS.MKDir		>STYA pPath				resolved path

				jsr MakeTrans2Reg

				ldx #0

.1				lda SMB.CreateDirectory,x
				sta (ZPReqPtr),y
				iny
				inx
				cpx #SMB.CreateDirectory.Len
				bne .1

				jsr AppendPath

				lda #0
				sta (ZPReqPtr),y
				iny

				jsr SetT2ReqLenYA

				pha
				>PUSHB MountTable+3		hSocket
				>PUSHW ZPReqPtr
				pla
				>PUSHYA

				ldx #LIBTCPIP.Send
			jsr GO.LIBTCPIP
				bcs .9

				jmp Sleep

.9				>RET 4
*--------------------------------------
CIFS2.MKDir		jsr ReadSocket
				bcs .9

				jsr GetRespData

				ldy #S.NETBIOS+S.SMB.H.STATUS
				lda (ZPRespPtr),y
				clc
				beq .8

				lda #MLI.E.DUPFILE
				sec
				
.8				jsr FreeRespData

				stz CIFS.Status
				>RET 4

.9				cmp #E.NODATA
				bne .99

				dec CIFS.Retries
				beq .98

				lda #0
				sec
				rts

.98				lda #MLI.E.IO

.99				sec
				stz CIFS.Status
				>RET 4
*--------------------------------------
CIFS.OpenDir	>STYA pPath				resolved path

				>LDYAI S.FD.DIR
				>SYSCALL2 GetMem
				bcs .9

				>STYA ZPPtr2

				lda #S.FD.T.DIR
				sta (ZPPtr2)

				lda hHandler
				ldy #S.FD.PFT
				sta (ZPPtr2),y

				lda #0
				ldy #S.FD.DIR.EPB
				sta (ZPPtr2),y			EOF Flag
				iny
				sta (ZPPtr2),y
				iny
				sta (ZPPtr2),y

				>PUSHW pPath
				>PUSHWI 0
				txa
				>PUSHA
				>SYSCALL2 mknod

.9				rts
*--------------------------------------
CIFS2.OpenDir	lda #MLI.E.BADCALL
				sec
				rts
*--------------------------------------
CIFS.ReadDir	jsr GetPFD

				jsr ClearSocket

				ldy #S.FD.DIR.EPB
				lda (pFD),y
				beq .1

				lda #MLI.E.EOF
				sec
				rts

.1				iny
				lda (pFD),y
				iny
				ora (pFD),y
				bne CIFS.ReadDir.Next

				jsr MakeTrans2Reg

				ldx #0

.2				lda SMB.FindFirst2,x
				sta (ZPReqPtr),y
				iny
				inx
				cpx #SMB.FindFirst2.Len
				bne .2

				bra CIFS.ReadDir.Send

CIFS.ReadDir.Next
				jsr MakeTrans2Reg

				ldx #0

.2				lda SMB.FindNext2,x
				sta (ZPReqPtr),y
				iny
				inx
				cpx #SMB.FindNext2.Len
				bne .2

				phy

				ldy #S.FD.DIR.FC+1
				lda (pFD),y
				tax
				dey
				lda (pFD),y

				ldy #S.NETBIOS+S.SMB.H+SMB.Trans2.H.Len+7				Search ID
				sta (ZPReqPtr),y
				txa
				iny
				sta (ZPReqPtr),y

				ply
CIFS.ReadDir.Send
				lda (pPath)
				beq .1

				jsr AppendPath

				lda #'\'
				sta (ZPReqPtr),y
				iny

.1				lda #'*'
				sta (ZPReqPtr),y
				iny
				lda #0
				sta (ZPReqPtr),y
				iny

				jsr SetT2ReqLenYA

				pha
				
				>PUSHB MountTable+3		hSocket
				>PUSHW ZPReqPtr
				pla
				>PUSHYA
				
				ldx #LIBTCPIP.Send
			jsr GO.LIBTCPIP
				bcs .9

				jmp Sleep

.9				rts
*--------------------------------------
CIFS2.ReadDir	jsr GetPFD

				jsr ReadSocket
				bcs .90

				jsr GetRespData

				ldy #S.NETBIOS+S.SMB.H.STATUS
				lda (ZPRespPtr),y
				beq .1

.91				sec
				lda #MLI.E.IO
				bra .9

.1				ldy #S.FD.DIR.FC
				lda (pFD),y
				iny
				ora (pFD),y
				sta bFlag
				bne .2

				ldy #S.NETBIOS+S.SMB.H+S.TRANS2.H+1		Search ID
				lda (ZPRespPtr),y
				tax
				dey
				ora (ZPRespPtr),y
				beq .91

				lda (ZPRespPtr),y
				
				ldy #S.FD.DIR.FC
				sta (pFD),y
				iny
				txa
				sta (pFD),y

.2				jsr GetRespDataOffset
				jsr CIFS2.ReadDir.GetBuf
				bcs .9

				jsr GetRespDataOffset
				jsr CIFS2.ReadDir.FillBuf

				lda hResp
				>SYSCALL2 FreeMem

				>LDYA BufPtr
				ldx hBuf
				
				stz CIFS.Status
				clc
				rts
				
.9				stz CIFS.Status
				
				jmp FreeRespData

.90				cmp #E.NODATA
				bne .99

				dec CIFS.Retries
				beq .98

				lda #0
				sec
				rts

.98				lda #MLI.E.IO

.99				stz CIFS.Status
				sec
				rts
*--------------------------------------
CIFS2.ReadDir.GetBuf
				ldy #S.NETBIOS+S.SMB.H+S.TRANS2.H		Search Count
				lda bFlag
				bne .10

				iny
				iny

.10				iny
				iny
				lda (ZPRespPtr),y		End Of Search
				phy
				ldy #S.FD.DIR.EPB
				sta (pFD),y
				ply

				dey
				dey

				lda (ZPRespPtr),y		Search Count
				beq .99
				tax

				lda #1					+Ending 0
				sta ZPPtr2
				stz ZPPtr2+1

.1				lda ZPPtr2
				clc
				adc #S.STAT
				sta ZPPtr2
				bcc .2

				inc ZPPtr2+1

.2				lda ZPPtr1
				clc
				adc #22
				sta ZPPtr1
				bcc .3

				inc ZPPtr1+1

.3				lda (ZPPtr1)			Filename Len
				pha
				sec
				adc ZPPtr2
				sta ZPPtr2
				bcc .4

				inc ZPPtr2+1

.4				pla
				inc
				sec
				adc ZPPtr1
				sta ZPPtr1
				bcc .5

				inc ZPPtr1+1

.5				dex
				bne .1

				>LDYA ZPPtr2
				>SYSCALL2 GetMem
				bcs .9

				>STYA BufPtr
				>STYA ZPPtr2
				stx hBuf

.9				rts

.99				lda #MLI.E.EOF
				sec
				rts
*--------------------------------------
CIFS2.ReadDir.FillBuf
				ldy #S.NETBIOS+S.SMB.H+S.TRANS2.H		Search Count
				lda bFlag
				bne .10

				iny
				iny

.10				lda (ZPRespPtr),y
				tax

.1				jsr FileInfo2StatBuf

				lda ZPPtr1
				sec						skip Filename Len
				adc #22
				sta ZPPtr1
				bcc .2

				inc ZPPtr1+1

.2				ldy #$ff

.3				iny
				lda (ZPPtr1),y
				sta (ZPPtr2),y
				bne .3

				tya
				sec
				adc ZPPtr1
				sta ZPPtr1
				bcc .4

				inc ZPPtr1+1

.4				tya
				sec
				adc ZPPtr2
				sta ZPPtr2
				bcc .5

				inc ZPPtr2+1

.5				jsr StatBuf2Ptr2

				lda #S.STAT
				clc
				adc ZPPtr2
				sta ZPPtr2
				bcc .7

				inc ZPPtr2+1

.7				dex
				bne .1

				lda #0
				sta (ZPPtr2)

				rts
*--------------------------------------
CIFS.CloseDir	tax

				lda Nod.Table.hName-2,x
				beq .1

				phx

				stz Nod.Table.hName-2,x
				>SYSCALL2 FreeMem

				plx

.1				lda Nod.Table.hFD-2,x
				stz Nod.Table.hFD-2,x
				>SYSCALL2 FreeMem

				stz CIFS.Status
				clc
				rts
*--------------------------------------
CIFS2.CloseDir	lda #MLI.E.INVPATH
				sec
				rts
*--------------------------------------
CIFS.ChOwn
CIFS2.ChOwn
				lda #MLI.E.BADCALL
				sec
				rts
*--------------------------------------
CIFS.FOpen


CIFS2.FOpen

				lda #MLI.E.BADCALL
				sec
				rts
*--------------------------------------
CIFS.FClose
CIFS2.FClose
CIFS.FRead
CIFS2.FRead
CIFS.FWrite
CIFS2.FWrite
CIFS.FFlush
CIFS2.FFlush
CIFS.FSeek
CIFS2.FSeek
CIFS.FTell
CIFS2.FTell
CIFS.FEOF
CIFS2.FEOF
CIFS.Remove
CIFS2.Remove
CIFS.Rename
CIFS2.Rename	
				lda #MLI.E.BADCALL
				sec
				rts
*--------------------------------------
MAN
SAVE usr/src/lib/libcifs.io.s
LOAD usr/src/lib/libcifs.s
ASM
