A2osX/SBIN/TCPIP.S.CFG.txt

374 lines
6.0 KiB
Plaintext
Raw Normal View History

2016-10-07 20:48:49 +00:00
PR#3
PREFIX /A2OSX.BUILD
2016-10-07 20:48:49 +00:00
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
CFG.Read >PUSHW L.HOSTNAME
>LDYA L.MSG.CFG
>SYSCALL PrintF.YA
2016-10-07 20:48:49 +00:00
jsr CFG.Read.HOSTNAME
bcc .1
>PUSHA
>LDYA L.MSG.CFG.KO
bra .2
.1 >LDYA L.MSG.CFG.OK
.2 >SYSCALL PrintF.YA
2016-10-07 20:48:49 +00:00
>PUSHW L.TCPIP.CONF
2016-10-07 20:48:49 +00:00
>LDYA L.MSG.CFG
>SYSCALL PrintF.YA
2016-10-07 20:48:49 +00:00
jsr CFG.Read.TCPIP.CONF
bcc .3
>PUSHA
>LDYA L.MSG.CFG.KO
bra .4
.3 >LDYA L.MSG.CFG.OK
.4 >SYSCALL PrintF.YA
2016-10-07 20:48:49 +00:00
>PUSHW L.HOSTS
2016-10-07 20:48:49 +00:00
>LDYA L.MSG.CFG
>SYSCALL PrintF.YA
2016-10-07 20:48:49 +00:00
jsr CFG.Read.HOSTS
bcc .5
>PUSHA
>LDYA L.MSG.CFG.KO
bra .6
.5 >SYSCALL PrintF.YA
.6 >LDYA L.MSG.CFG.OK
>SYSCALL PrintF.YA
rts
2016-10-07 20:48:49 +00:00
*--------------------------------------
CFG.Read.HOSTNAME
stz CFG.hCfgFile
stz CFG.hCfgPath
>LDYA L.HOSTNAME
>SYSCALL ExpandStr.YA
bcs .99
stx CFG.hCfgPath
pha
2016-10-07 20:48:49 +00:00
>PUSHWI 0 Aux type
>PUSHBI 4 S.FILEINFO.TYPE.TXT
2017-01-12 17:43:45 +00:00
>PUSHBI SYS.FOpen.R
pla
>PUSHYA
>SYSCALL LoadFile
bcs .9
2016-10-07 20:48:49 +00:00
stx CFG.hCfgFile
>STYA CFG.FileLen
txa
>SYSCALL GetMemPtr.A
2016-10-07 20:48:49 +00:00
>STYA ZPIPCfgPtr
* read 15 chars MAX, until CR or EOF
ldx #$15
2016-10-07 20:48:49 +00:00
lda CFG.FileLen+1
bne .1 File is more than 256....?
ldx CFG.FileLen
beq .9 len is 0 !!!
.1 ldy #0
2016-10-07 20:48:49 +00:00
.2 lda (ZPIPCfgPtr),y
cmp #13
beq .8 A CR, end of name
iny
2016-10-07 20:48:49 +00:00
sta IPCFG+S.IPCFG.HOSTNAME,y
dex
bne .2
2016-10-07 20:48:49 +00:00
.8 sty IPCFG+S.IPCFG.HOSTNAME
jsr CFG.Read.CleanUp
clc
2016-10-07 20:48:49 +00:00
rts
.9 jsr CFG.Read.CleanUp
sec
2016-10-07 20:48:49 +00:00
.99 rts
*--------------------------------------
CFG.Read.TCPIP.CONF
stz CFG.hCfgFile
stz CFG.hCfgPath
>LDYA L.TCPIP.CONF
>SYSCALL ExpandStr.YA
bcs .99
stx CFG.hCfgPath
pha
2016-10-07 20:48:49 +00:00
>PUSHWI 0 Aux type
>PUSHBI 4 S.FILEINFO.TYPE.TXT
2017-01-12 17:43:45 +00:00
>PUSHBI SYS.FOpen.R
pla
>PUSHYA
>SYSCALL LoadFile
bcs .9
2016-10-07 20:48:49 +00:00
stx CFG.hCfgFile
>STYA CFG.FileLen
txa
>SYSCALL GetMemPtr.A
2016-10-07 20:48:49 +00:00
>STYA ZPIPCfgPtr
.1 jsr CFG.GetLine
bcs .8
2016-10-07 20:48:49 +00:00
jsr CFG.GetKeyword
bcs .1
lda CFG.Keyword
bne .3
ldy UsrBuf256
lda UsrBuf256+1,y
cmp #35 DOMAIN too long!!!
bcs .1
sta IPCFG+S.IPCFG.DOMAIN
ldx #0
.2 lda UsrBuf256+2,y
sta IPCFG+S.IPCFG.DOMAIN,x
beq .1
inx
iny
bne .2
bra .1
.9 jsr CFG.Read.CleanUp
sec
.99 rts
2016-10-07 20:48:49 +00:00
.3 jsr CFG.ScanIP
bcs .1
ldy CFG.Keyword
lda CFG.Keyword.Map,y
tax
ldy #0
.4 lda CFG.IP+1,y
sta IPCFG,x
inx
iny
cpy #4
bne .4
lda CFG.Keyword
cmp #1
bne .1
lda #S.IPCFG.STATUS.OK
sta IPCFG
bra .1
.8 jsr CFG.Read.CleanUp
2016-10-07 20:48:49 +00:00
clc
rts
2016-10-07 20:48:49 +00:00
*--------------------------------------
CFG.Read.HOSTS >PUSHWI 0 Aux type
>PUSHBI 4 S.FILEINFO.TYPE.TXT
2017-01-12 17:43:45 +00:00
>PUSHBI SYS.FOpen.R
2016-10-07 20:48:49 +00:00
>PUSHW L.HOSTS
>SYSCALL LoadFile
2016-10-07 20:48:49 +00:00
bcs .99
stx CFG.hCfgFile
>STYA CFG.FileLen
txa
>SYSCALL GetMemPtr.A
2016-10-07 20:48:49 +00:00
>STYA ZPIPCfgPtr
.89 lda CFG.hCfgFile
>SYSCALL FreeMem.A
2016-10-07 20:48:49 +00:00
clc
.99 rts
*--------------------------------------
CFG.Read.CleanUp
pha
lda CFG.hCfgPath
beq .1
>SYSCALL FreeMem.A
.1 lda CFG.hCfgFile
beq .8
>SYSCALL FreeMem.A
.8 pla
rts
*--------------------------------------
2016-10-07 20:48:49 +00:00
CFG.GetLine stz UsrBuf256
ldx #0
ldy #0
.1 jsr CFG.GetChar
bne .2 end of file?
txa
bne .8
sec
rts
.2 cmp #$0D
beq .8 end of line
inx
sta UsrBuf256,x
cmp #'='
bne .3
txa
dec
tay
.3 cpx #64 line too long ?
bne .1
sec
rts
.8 tya = found ?
beq .9
sta UsrBuf256
txa
sec
sbc UsrBuf256
sta UsrBuf256+1,y
stz UsrBuf256+1,x End with 0 for ScanIP
clc
rts
.9 sec
rts
*--------------------------------------
CFG.GetChar lda CFG.FileLen
bne .1
lda CFG.FileLen+1
beq .9
dec CFG.FileLen+1
.1 dec CFG.FileLen
lda (ZPIPCfgPtr)
inc ZPIPCfgPtr
bne .9
inc ZPIPCfgPtr+1 NZ
.9 rts
*--------------------------------------
CFG.GetKeyword stz CFG.Keyword
ldx #0
.1 phx
ldy #0
.2 lda CFG.Keywords,x
cmp UsrBuf256,y
bne .3
cpy UsrBuf256
beq .4
inx
iny
bne .2
plx
sec
rts
.3 inc CFG.Keyword
plx
txa
sec
adc CFG.Keywords,x
tax
lda CFG.Keywords,x
bne .1
sec
rts
.4 plx
clc
rts
*--------------------------------------
CFG.ScanIP stz CFG.IP
ldx UsrBuf256
.1 ldy #0
.11 lda UsrBuf256+2,x
beq .3
cmp #'0'
bcc .2
cmp #'9'+1
bcs .2
cpy #3
beq .9
iny
sta CFG.StrBuf,y
inx
bra .11
.2 cmp #'.'
bne .9
.3 sty CFG.StrBuf
lda CFG.IP
cmp #4
beq .9
jsr CFG.Dec2Hex
bcs .9
lda CFG.HexByte
inc CFG.IP
ldy CFG.IP
sta CFG.IP,y
inx
lda UsrBuf256+1,x
bne .1
clc
rts
.9 sec
rts
*--------------------------------------
CFG.Dec2Hex sec
ldy CFG.StrBuf
beq .9
lda CFG.StrBuf+1
and #$0f
sta CFG.HexByte
ldy #1
.1 cpy CFG.StrBuf
beq .8
iny
lda CFG.HexByte
asl CFG.HexByte
bcs .9
asl CFG.HexByte
bcs .9
adc CFG.HexByte
bcs .9
asl
bcs .9
sta CFG.HexByte
lda CFG.StrBuf,y
and #$0f
adc CFG.HexByte
sta CFG.HexByte
bcc .1
.9 rts
.8 clc
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SBIN/TCPIP.S.CFG
LOAD /A2OSX.SRC/SBIN/TCPIP.S
2016-10-07 20:48:49 +00:00
ASM