A2osX/BIN/IPCONFIG.S.ETC.txt
2020-04-07 08:01:38 +02:00

347 lines
5.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
CFG.EtcFiles >LDYAI 256
>SYSCALL GetMem
bcc .1
rts
.1 >STYA ZPTmpPtr1
stx CFG.hBuf1
>LDYA L.HOSTNAME
jsr CFG.Read.PrintF
jsr CFG.Read.HOSTNAME
lda IPCFG+S.IPCFG.HOSTNAME
bne .4
>PUSHW L.IPCFG.HOSTNAME
>PUSHW L.CFG.DefaultHost
>PUSHW A2osX.TIMER16
>PUSHBI 2
>SYSCALL sprintf
.4 >LDYA L.TCPIP.CONF
jsr CFG.Read.PrintF
jsr CFG.Read.TCPIP.CONF
lda IPCFG+S.IPCFG.IP
beq .5
lda #S.IPCFG.STATUS.OK
sta IPCFG+S.NETCFG.STATUS
.5 >LDYA L.HOSTS
jsr CFG.Read.PrintF
jsr CFG.Read.HOSTS
>PUSHW L.IPCFG
>LIBCALL hLIBTCPIP,LIBTCPIP.SETCFG
lda CFG.hBuf1
>SYSCALL FreeMem
.9 rts
*--------------------------------------
CFG.Read.PrintF pha
>PUSHW L.MSG.CFG
pla
>PUSHYA
>PUSHBI 2
>SYSCALL PrintF
rts
*--------------------------------------
CFG.Read.HOSTNAME
>LDYA L.HOSTNAME
jsr CFG.Read.Open
jsr CFG.Read.Result
bcs .9
.1 jsr CFG.Read.GetS
bcs .8
lda (ZPTmpPtr1)
beq .1 empty line...
cmp #'#
beq .1 comment...
ldy #0
.2 lda (ZPTmpPtr1),y
sta IPCFG+S.IPCFG.HOSTNAME,y
beq .8 end of name
iny
cpy #15
bne .2
.8 clc
.HS B0 BCS
.9 sec
jmp CFG.Read.Close
*--------------------------------------
CFG.Read.TCPIP.CONF
>LDYA L.TCPIP.CONF
jsr CFG.Read.Open
jsr CFG.Read.Result
bcs .9
.1 jsr CFG.Read.GetS
bcs .8
lda (ZPTmpPtr1)
beq .1 empty line...
cmp #'#'
beq .1 comment...
ldy #$ff
.2 iny
lda (ZPTmpPtr1),y
beq .3
cmp #C.SPACE
bne .2
.3 lda L.CFG.Keywords
sta ZPTmpPtr2
lda L.CFG.Keywords+1
sta ZPTmpPtr2+1
ldx #0
.4 phy save keyword len
tya
cmp (ZPTmpPtr2)
bne .6
.5 lda (ZPTmpPtr2),y
dey
cmp (ZPTmpPtr1),y
bne .6
tya
bne .5
ply discard keyword len
jsr .80
bra .1
.6 lda (ZPTmpPtr2)
sec
adc ZPTmpPtr2
sta ZPTmpPtr2
bcc .7
inc ZPTmpPtr2+1
.7 inx
inx
ply reset keyword len
lda (ZPTmpPtr2)
bne .4
bra .1
.8 clc
.HS B0 BCS
.9 sec
jmp CFG.Read.Close
.80 jmp (J.CFG.Keywords,x)
*--------------------------------------
CFG.Read.address
ldx #S.IPCFG.IP
bra CFG.Read.IP
CFG.Read.netmask
ldx #S.IPCFG.MASK
bra CFG.Read.IP
CFG.Read.gateway
ldx #S.IPCFG.GW
bra CFG.Read.IP
CFG.Read.nameserver
ldx #S.IPCFG.DNS1
lda IPCFG,x
beq CFG.Read.IP
ldx #S.IPCFG.DNS2
lda IPCFG,x
beq CFG.Read.IP
clc
rts
CFG.Read.IP lda (ZPTmpPtr2)
sec
adc ZPTmpPtr1
tay
lda ZPTmpPtr1+1
adc #0
>PUSHYA
>PUSHW L.CFG.IP.SScanF
ldy #4
.1 txa
clc
adc L.IPCFG
pha
lda L.IPCFG+1
adc #0
>PUSHA @IP[0][1][2][3]
pla
>PUSHA
inx
dey
bne .1
>PUSHBI 8 4 PTRs on stack
>SYSCALL SScanF
rts
CFG.Read.dnsdomain
lda (ZPTmpPtr2)
sec
adc ZPTmpPtr1
sta ZPTmpPtr1
bcc .1
inc ZPTmpPtr1+1
.1 ldy #$ff
.2 iny
lda (ZPTmpPtr1),y
sta IPCFG+S.IPCFG.DOMAIN,y
beq .8
cpy #K.DNS.MAXLEN
bne .2
lda #0
sta IPCFG+S.IPCFG.DOMAIN,y
.8 rts
*--------------------------------------
CFG.Read.HOSTS stz CFG.hBuf2
stz CFG.hBuf3
>LDYA L.HOSTS
jsr CFG.Read.Open
jsr CFG.Read.Result
bcs .9
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPTmpPtr2
stx CFG.hBuf2
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPTmpPtr3
stx CFG.hBuf3
.1 jsr CFG.Read.GetS
bcs .8
lda (ZPTmpPtr1)
beq .1 empty line...
cmp #'#
beq .1 comment...
jsr CFG.Read.HOSTS.Scan
bcs .1
cmp #5
bcc .1 less than 5 parameters, ignore
beq .2 no alias
>LDYA ZPTmpPtr3
jsr CFG.DNS.Add
.2 >LDYA ZPTmpPtr2
jsr CFG.DNS.Add
bra .1
.8 clc
.HS B0 BCS
.9 sec
php
pha
lda CFG.hBuf3
beq .90
>SYSCALL FreeMem
.90 lda CFG.hBuf2
beq .91
>SYSCALL FreeMem
.91 jmp CFG.Read.Close2
*--------------------------------------
CFG.Read.HOSTS.Scan
>PUSHW L.CFG.HOST.SScanF
>LDYA ZPTmpPtr1
ldx #0
.2 txa
clc
adc L.CFG.IP
tay
lda L.CFG.IP+1
adc #0
>PUSHYA @IP[].....
inx
cpx #4
bne .2
>PUSHW ZPTmpPtr2
>PUSHW ZPTmpPtr3
>PUSHBI 12 6 PTRs on stack
>SYSCALL SScanF
rts
*--------------------------------------
CFG.DNS.ADD >STYA ZPTmpPtr1
>LDYA L.CFG.IP
>PUSHYA
>PUSHW ZPTmpPtr1
>LIBCALL hLIBTCPIP,LIBTCPIP.DNS.Add
*--------------------------------------
CFG.Read.Result bcc .1
pha
>PUSHW L.MSG.CFG.KO
pla
>PUSHA
>PUSHBI 1
>SYSCALL PrintF
sec
rts
.1 >LDYA L.MSG.CFG.OK
>SYSCALL PutS
rts
*--------------------------------------
CFG.Read.Open stz CFG.hCfgFile
>PUSHYA
>PUSHBI O.RDONLY
>PUSHBI S.FI.T.TXT
>PUSHWZ
>SYSCALL FOpen
bcs .9
sta CFG.hCfgFile
* clc
.9 rts
*--------------------------------------
CFG.Read.Close php
pha
CFG.Read.Close2 lda CFG.hCfgFile
beq .8
>SYSCALL FClose
.8 pla
plp
rts
*--------------------------------------
CFG.Read.GetS >PUSHWI 255
>PUSHW ZPTmpPtr1
lda CFG.hCfgFile
>SYSCALL fgets
rts
*--------------------------------------
MAN
SAVE USR/SRC/SBIN/IPCONFIG.S.ETC
LOAD USR/SRC/SBIN/IPCONFIG.S
ASM