mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-23 07:35:19 +00:00
398 lines
6.5 KiB
Plaintext
398 lines
6.5 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
ENVX.hEnv .BS 1
|
||
ENVX.hSID .BS 1
|
||
*--------------------------------------
|
||
ENVX.PutEnv.9 lda #E.SYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
ENVX.PutEnv tax save hEnv
|
||
sty ENVX.hSID
|
||
|
||
ldy #$ff
|
||
|
||
.1 iny
|
||
jsr SHARED.TXTPTR.GetY NAME=
|
||
beq ENVX.PutEnv.9
|
||
|
||
cmp #'='
|
||
bne .1
|
||
|
||
tya
|
||
sec skip =
|
||
adc TXTPTR
|
||
sta FORPNT
|
||
|
||
lda #0
|
||
adc TXTPTR+1
|
||
sta FORPNT+1
|
||
|
||
txa get back hEnv
|
||
ldy ENVX.hSID
|
||
*--------------------------------------
|
||
ENVX.SetEnv jsr ENVX.UnsetEnv
|
||
|
||
.1 jsr ENVX.InitEnvP3
|
||
|
||
lda #1
|
||
sta ZPPtr4
|
||
stz ZPPtr4+1 ZPPtr4 = ENVSIZE = 1
|
||
|
||
.10 lda (ZPPtr3) End of ENV
|
||
beq .15
|
||
|
||
jsr ENVX.GetP3LenY
|
||
jsr ENVX.NextEnvP3Y
|
||
jsr ENVX.NextEnvP4Y
|
||
bra .10
|
||
|
||
.15 ldy #$ff
|
||
|
||
.16 iny
|
||
jsr SHARED.TXTPTR.GetY
|
||
beq .17
|
||
|
||
jsr SHARED.IsIDValid
|
||
bcc .16
|
||
|
||
.17 jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR
|
||
|
||
ldy #$ff
|
||
|
||
.19 iny
|
||
jsr SHARED.FORPNT.getY
|
||
bne .19
|
||
|
||
jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE
|
||
lda ZPPtr4
|
||
beq .20
|
||
|
||
inc ZPPtr4+1
|
||
|
||
.20 lda ENVX.hEnv
|
||
jsr MEM.GetMemByID
|
||
|
||
lda ZPPtr4+1
|
||
ldy #S.MEM.LEN+1
|
||
cmp (ZPMemMgrSPtr),y
|
||
bcs .22 env is large enough
|
||
|
||
sta MEM.NewSize+1
|
||
stz MEM.NewSize
|
||
jsr K.realloc.I
|
||
bcs .9
|
||
|
||
stx ENVX.hEnv
|
||
txa
|
||
sta CLRWRITEAUX
|
||
ldy #S.PS.hENV
|
||
lda (pPS),y
|
||
sta SETWRITEAUX
|
||
bra .1 Start over
|
||
|
||
.22 ldy #$ff
|
||
|
||
.23 iny
|
||
jsr SHARED.TXTPTR.GetY
|
||
sta (ZPPtr3),y
|
||
beq .24
|
||
jsr SHARED.IsIDValid
|
||
bcc .23
|
||
|
||
.24 lda #'='
|
||
sta (ZPPtr3),y
|
||
|
||
jsr ENVX.NextEnvP3Y
|
||
ldy #$ff
|
||
|
||
.25 iny
|
||
jsr SHARED.FORPNT.getY
|
||
sta (ZPPtr3),y
|
||
bne .25
|
||
|
||
iny
|
||
sta (ZPPtr3),y don't forget array ending 0
|
||
clc
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
ENVX.GetEnv sta ENVX.hEnv
|
||
sty ENVX.hSID
|
||
|
||
ldy TXTPTR+1
|
||
bne .10
|
||
|
||
tax hMem for CopyToMain
|
||
|
||
jsr MEM.GetMemByID
|
||
|
||
ldy #S.MEM.LEN
|
||
lda (ZPMemMgrSPtr),y
|
||
pha
|
||
iny
|
||
lda (ZPMemMgrSPtr),y
|
||
ply YA = Len
|
||
|
||
jmp MEM.CopyToMain
|
||
*--------------------------------------
|
||
.10 jsr ENVX.FindEnvVar
|
||
bcc .11
|
||
|
||
jsr ENVX.FindSIDVar
|
||
bcs .9
|
||
|
||
>STYA ZPPtr3
|
||
bra .12
|
||
|
||
.11 jsr ENVX.NextEnvP3Y Skip NAME=
|
||
|
||
.12 lda FORPNT+1
|
||
bne .3
|
||
|
||
ldy #$ff
|
||
|
||
.1 iny
|
||
lda (ZPPtr3),y
|
||
bne .1
|
||
|
||
iny
|
||
bne .2
|
||
inc
|
||
|
||
.2 ldx #SYS.GetMem
|
||
jsr K.SYSCALL2.MAIN !!! Get a buffer In MAIN Mem !!!
|
||
|
||
bcs .99
|
||
|
||
>STYA FORPNT
|
||
|
||
.3 ldy #$ff
|
||
|
||
.4 iny
|
||
lda (ZPPtr3),y
|
||
jsr SHARED.FORPNT.PutY
|
||
bne .4
|
||
|
||
>LDYA FORPNT
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.NOKEY
|
||
|
||
* sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
ENVX.UnsetEnv sta ENVX.hEnv
|
||
sty ENVX.hSID
|
||
|
||
jsr ENVX.FindEnvVar
|
||
bcs .8 not found, quit
|
||
|
||
jsr ENVX.DelVarP3 Ptr3 -> NAME=VALUE
|
||
.8 clc
|
||
|
||
rts
|
||
*--------------------------------------
|
||
* ENV.FindEnvVar
|
||
* In:
|
||
* TXTPTR -> NAME
|
||
* Out:
|
||
* CC: Found
|
||
* Y = NAME len
|
||
* TXTPTR -> NAME
|
||
* ZPPtr3 -> NAME=VALUE
|
||
* CS: Not Found
|
||
* TXTPTR -> NAME
|
||
* ZPPtr3 -> PTR to Ending 0
|
||
*--------------------------------------
|
||
ENVX.FindEnvVar jsr ENVX.InitEnvP3 Store ENV
|
||
|
||
.1 lda (ZPPtr3)
|
||
beq .9 end of ENV
|
||
|
||
ldy #$ff
|
||
|
||
.2 iny
|
||
jsr SHARED.TXTPTR.GetY
|
||
beq .3
|
||
|
||
jsr SHARED.IsIDValid
|
||
bcs .3
|
||
|
||
cmp (ZPPtr3),y
|
||
beq .2
|
||
|
||
bra .4
|
||
|
||
.3 lda (ZPPtr3),y
|
||
cmp #'='
|
||
bne .4
|
||
|
||
clc
|
||
rts
|
||
|
||
.4 jsr ENVX.NextEnvP3 Skip NAME=VALUE
|
||
bra .1
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
ENVX.FindSIDVar >LDYAI ENVX.SIDVars
|
||
>STYA ZPPtr3
|
||
ldx #0
|
||
|
||
.1 lda (ZPPtr3)
|
||
beq .9
|
||
|
||
ldy #$ff
|
||
|
||
.2 iny
|
||
jsr SHARED.TXTPTR.GetY
|
||
beq .3
|
||
|
||
jsr SHARED.IsIDValid
|
||
bcs .3
|
||
|
||
cmp (ZPPtr3),y
|
||
beq .2
|
||
|
||
bra .4
|
||
|
||
.3 lda (ZPPtr3),y
|
||
bne .4
|
||
|
||
jmp (ENVX.SIDVarsJmp,x)
|
||
|
||
.4 inx
|
||
inx
|
||
jsr ENVX.NextEnvP3
|
||
bra .1
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
ENVX.SIDVars .AZ "LOGNAME"
|
||
.AZ "GECOS"
|
||
.AZ "HOME"
|
||
.AZ "SHELL"
|
||
.AZ "UID"
|
||
.AZ "GID"
|
||
.DA #0
|
||
*--------------------------------------
|
||
ENVX.SIDVarsJmp .DA ENVX.SIDVarsSTR
|
||
.DA ENVX.SIDVarsSTR
|
||
.DA ENVX.SIDVarsSTR
|
||
.DA ENVX.SIDVarsSTR
|
||
.DA ENVX.SIDVarsUID
|
||
.DA ENVX.SIDVarsGID
|
||
*--------------------------------------
|
||
ENVX.SIDVarsSTR jsr ENVX.InitSIDP3
|
||
|
||
lda ZPPtr3
|
||
clc
|
||
adc #S.SESSION.NAME
|
||
sta ZPPtr3
|
||
lda ZPPtr3+1
|
||
adc /S.SESSION.NAME
|
||
sta ZPPtr3+1
|
||
|
||
.1 dex
|
||
dex
|
||
bmi .8
|
||
|
||
ldy #$ff
|
||
|
||
.2 iny
|
||
lda (ZPPtr3),y
|
||
bne .2
|
||
|
||
jsr ENVX.NextEnvP3Y
|
||
bra .1
|
||
|
||
.8 >LDYA ZPPtr3
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
ENVX.SIDVarsUID ldx #S.SESSION.UID
|
||
.HS 2C
|
||
ENVX.SIDVarsGID ldx #S.SESSION.GID
|
||
|
||
jsr ENVX.InitSIDP3
|
||
txa
|
||
tay
|
||
lda (ZPPtr3),y
|
||
|
||
jsr MATH32.A2STR10NP
|
||
|
||
>LDYAI A2osX.NumStrBuf
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* ENV.DelVarP3
|
||
* In:
|
||
* ZPPtr3 -> ENV.NAME to Discard
|
||
*--------------------------------------
|
||
ENVX.DelVarP3 >LDYA ZPPtr3 save actual Ptr
|
||
>STYA ZPPtr4
|
||
jsr ENVX.NextEnvP3 Skip NAME=VALUE
|
||
|
||
.1 ldy #$ff
|
||
|
||
.2 iny
|
||
lda (ZPPtr3),y Move back CSTRs...
|
||
sta (ZPPtr4),y
|
||
bne .2
|
||
|
||
tya
|
||
|
||
beq .8 we moved back ending \0
|
||
|
||
jsr ENVX.NextEnvP3Y
|
||
jsr ENVX.NextEnvP4Y
|
||
bra .1
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
ENVX.InitEnvP3 lda ENVX.hEnv
|
||
bra ENVX.InitP3
|
||
*--------------------------------------
|
||
ENVX.InitSIDP3 lda ENVX.hSID
|
||
|
||
ENVX.InitP3 jsr K.GetMemPtr
|
||
>STYA ZPPtr3
|
||
rts
|
||
*--------------------------------------
|
||
ENVX.NextEnvP3 jsr ENVX.GetP3LenY
|
||
*--------------------------------------
|
||
ENVX.NextEnvP3Y tya
|
||
ENVX.NextEnvP3A sec
|
||
adc ZPPtr3
|
||
sta ZPPtr3
|
||
bcc .8
|
||
inc ZPPtr3+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
ENVX.GetP3LenY ldy #$ff
|
||
.1 iny
|
||
lda (ZPPtr3),y
|
||
bne .1
|
||
rts
|
||
*--------------------------------------
|
||
ENVX.NextEnvP4Y tya
|
||
sec
|
||
adc ZPPtr4
|
||
sta ZPPtr4
|
||
bcc .8
|
||
inc ZPPtr4+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/SYS/KERNEL.S.ENVX
|
||
LOAD USR/SRC/SYS/KERNEL.S
|
||
ASM
|