A2osX/SYS/KERNEL.S.ENVX.txt

398 lines
6.5 KiB
Plaintext
Raw Normal View History

2020-01-22 16:31:48 +00:00
NEW
AUTO 3,1
*--------------------------------------
2020-02-02 14:58:01 +00:00
ENVX.hEnv .BS 1
2020-03-12 16:44:11 +00:00
ENVX.hSID .BS 1
2020-02-02 14:58:01 +00:00
*--------------------------------------
2020-02-06 16:23:59 +00:00
ENVX.PutEnv.9 lda #E.SYN
sec
rts
*--------------------------------------
ENVX.PutEnv tax save hEnv
2020-03-12 16:44:11 +00:00
sty ENVX.hSID
2020-02-06 16:23:59 +00:00
ldy #$ff
2020-01-22 16:31:48 +00:00
.1 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.TXTPTR.GetY NAME=
2020-02-06 16:23:59 +00:00
beq ENVX.PutEnv.9
2020-01-22 16:31:48 +00:00
cmp #'='
bne .1
tya
sec skip =
adc TXTPTR
sta FORPNT
lda #0
adc TXTPTR+1
sta FORPNT+1
2020-02-06 16:23:59 +00:00
txa get back hEnv
2020-03-13 16:10:36 +00:00
ldy ENVX.hSID
2020-01-22 16:31:48 +00:00
*--------------------------------------
ENVX.SetEnv jsr ENVX.UnsetEnv
2020-02-03 19:41:04 +00:00
.1 jsr ENVX.InitEnvP3
2020-01-22 16:31:48 +00:00
lda #1
sta ZPPtr4
stz ZPPtr4+1 ZPPtr4 = ENVSIZE = 1
.10 lda (ZPPtr3) End of ENV
beq .15
2020-01-29 16:46:51 +00:00
jsr ENVX.GetP3LenY
jsr ENVX.NextEnvP3Y
jsr ENVX.NextEnvP4Y
2020-01-22 16:31:48 +00:00
bra .10
2020-01-29 16:46:51 +00:00
.15 ldy #$ff
2020-01-22 16:31:48 +00:00
.16 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.TXTPTR.GetY
2020-01-22 16:31:48 +00:00
beq .17
jsr SHARED.IsIDValid
bcc .16
2020-01-29 16:46:51 +00:00
.17 jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR
2020-01-22 16:31:48 +00:00
ldy #$ff
.19 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.getY
2020-01-22 16:31:48 +00:00
bne .19
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE
2020-01-22 16:31:48 +00:00
lda ZPPtr4
beq .20
inc ZPPtr4+1
2020-02-03 15:17:34 +00:00
.20 lda ENVX.hEnv
jsr MEM.GetMemByID
2020-01-22 16:31:48 +00:00
lda ZPPtr4+1
2020-02-03 15:17:34 +00:00
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
2020-01-22 16:31:48 +00:00
bcs .9
2020-02-03 15:17:34 +00:00
stx ENVX.hEnv
txa
sta CLRWRITEAUX
2020-01-22 16:31:48 +00:00
ldy #S.PS.hENV
2020-02-28 07:21:46 +00:00
lda (pPS),y
2020-02-03 15:17:34 +00:00
sta SETWRITEAUX
2020-01-22 16:31:48 +00:00
bra .1 Start over
.22 ldy #$ff
2020-01-29 16:46:51 +00:00
2020-01-22 16:31:48 +00:00
.23 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.TXTPTR.GetY
2020-01-22 16:31:48 +00:00
sta (ZPPtr3),y
beq .24
jsr SHARED.IsIDValid
bcc .23
.24 lda #'='
sta (ZPPtr3),y
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y
2020-01-22 16:31:48 +00:00
ldy #$ff
.25 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.getY
2020-01-22 16:31:48 +00:00
sta (ZPPtr3),y
bne .25
iny
sta (ZPPtr3),y don't forget array ending 0
clc
2020-01-29 16:46:51 +00:00
.9 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-03-13 16:10:36 +00:00
ENVX.GetEnv sta ENVX.hEnv
sty ENVX.hSID
2020-03-12 16:44:11 +00:00
ldy TXTPTR+1
2020-02-04 20:04:33 +00:00
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
2020-03-13 07:15:58 +00:00
*--------------------------------------
.10 jsr ENVX.FindEnvVar
2020-03-12 16:44:11 +00:00
bcc .11
jsr ENVX.FindSIDVar
2020-01-22 16:31:48 +00:00
bcs .9
2020-03-13 07:15:58 +00:00
2020-03-12 16:44:11 +00:00
>STYA ZPPtr3
bra .12
2020-01-22 16:31:48 +00:00
2020-03-12 16:44:11 +00:00
.11 jsr ENVX.NextEnvP3Y Skip NAME=
2020-01-22 16:31:48 +00:00
2020-03-12 16:44:11 +00:00
.12 lda FORPNT+1
2020-01-22 16:31:48 +00:00
bne .3
ldy #$ff
.1 iny
lda (ZPPtr3),y
bne .1
iny
bne .2
inc
2020-02-03 15:17:34 +00:00
.2 ldx #SYS.GetMem
jsr K.SYSCALL2.MAIN !!! Get a buffer In MAIN Mem !!!
2020-01-29 16:46:51 +00:00
2020-01-22 16:31:48 +00:00
bcs .99
>STYA FORPNT
2020-01-29 16:46:51 +00:00
.3 ldy #$ff
2020-01-22 16:31:48 +00:00
.4 iny
lda (ZPPtr3),y
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.PutY
2020-01-22 16:31:48 +00:00
bne .4
>LDYA FORPNT
clc
rts
2020-07-09 11:34:07 +00:00
.9 lda #E.NOKEY
2020-02-03 15:17:34 +00:00
2020-01-22 16:31:48 +00:00
* sec
.99 rts
2020-01-29 16:46:51 +00:00
*--------------------------------------
2020-02-03 15:17:34 +00:00
ENVX.UnsetEnv sta ENVX.hEnv
2020-03-12 16:44:11 +00:00
sty ENVX.hSID
jsr ENVX.FindEnvVar
2020-02-02 14:58:01 +00:00
bcs .8 not found, quit
2020-01-22 16:31:48 +00:00
2020-01-29 16:46:51 +00:00
jsr ENVX.DelVarP3 Ptr3 -> NAME=VALUE
2020-02-02 14:58:01 +00:00
.8 clc
2020-01-22 16:31:48 +00:00
rts
*--------------------------------------
2020-03-12 16:44:11 +00:00
* ENV.FindEnvVar
2020-01-22 16:31:48 +00:00
* In:
* TXTPTR -> NAME
* Out:
* CC: Found
* Y = NAME len
* TXTPTR -> NAME
* ZPPtr3 -> NAME=VALUE
* CS: Not Found
* TXTPTR -> NAME
* ZPPtr3 -> PTR to Ending 0
*--------------------------------------
2020-03-12 16:44:11 +00:00
ENVX.FindEnvVar jsr ENVX.InitEnvP3 Store ENV
2020-01-22 16:31:48 +00:00
.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
2020-01-29 16:46:51 +00:00
.4 jsr ENVX.NextEnvP3 Skip NAME=VALUE
2020-01-22 16:31:48 +00:00
bra .1
2020-01-29 16:46:51 +00:00
.9 sec
2020-01-22 16:31:48 +00:00
rts
*--------------------------------------
2020-03-12 16:44:11 +00:00
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
2020-03-16 06:50:15 +00:00
jsr MATH32.A2STR10NP
2020-03-12 16:44:11 +00:00
2020-03-13 16:10:36 +00:00
>LDYAI A2osX.NumStrBuf
2020-03-12 16:44:11 +00:00
clc
rts
*--------------------------------------
2020-01-22 16:31:48 +00:00
* ENV.DelVarP3
* In:
* ZPPtr3 -> ENV.NAME to Discard
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.DelVarP3 >LDYA ZPPtr3 save actual Ptr
2020-01-22 16:31:48 +00:00
>STYA ZPPtr4
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3 Skip NAME=VALUE
2020-01-22 16:31:48 +00:00
.1 ldy #$ff
.2 iny
lda (ZPPtr3),y Move back CSTRs...
sta (ZPPtr4),y
bne .2
tya
beq .8 we moved back ending \0
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y
jsr ENVX.NextEnvP4Y
2020-01-22 16:31:48 +00:00
bra .1
2020-01-29 16:46:51 +00:00
.8 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-02-02 14:58:01 +00:00
ENVX.InitEnvP3 lda ENVX.hEnv
2020-03-12 16:44:11 +00:00
bra ENVX.InitP3
*--------------------------------------
ENVX.InitSIDP3 lda ENVX.hSID
2020-03-13 16:10:36 +00:00
2020-03-12 16:44:11 +00:00
ENVX.InitP3 jsr K.GetMemPtr
>STYA ZPPtr3
2020-01-22 16:31:48 +00:00
rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP3 jsr ENVX.GetP3LenY
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP3Y tya
ENVX.NextEnvP3A sec
2020-01-22 16:31:48 +00:00
adc ZPPtr3
sta ZPPtr3
bcc .8
inc ZPPtr3+1
.8 rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.GetP3LenY ldy #$ff
2020-01-22 16:31:48 +00:00
.1 iny
lda (ZPPtr3),y
bne .1
rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP4Y tya
2020-01-22 16:31:48 +00:00
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