2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-05-25 19:24:07 +00:00
|
|
|
|
AUTO 3,1
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # ExpandStr
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2017-08-28 15:35:10 +00:00
|
|
|
|
* Y,A = PTR to String to Expand (C-String)
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2017-08-28 15:35:10 +00:00
|
|
|
|
* X = hMem to Expanded String (C-String)
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* Y,A = PTR to Expanded String
|
|
|
|
|
*\--------------------------------------
|
2019-01-04 13:17:31 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPDRV
|
|
|
|
|
ENV.SearchPath .BS 2
|
|
|
|
|
ENV.BufLen .BS 1
|
2019-09-09 15:38:37 +00:00
|
|
|
|
ENV.VarEndChar .BS 1
|
2019-01-04 13:17:31 +00:00
|
|
|
|
ENV.bNoExp .BS 1
|
2019-07-22 06:31:01 +00:00
|
|
|
|
ENV.hMem .BS 1
|
|
|
|
|
ENV.bExp .BS 1
|
2019-01-04 13:17:31 +00:00
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
2019-07-22 06:31:01 +00:00
|
|
|
|
K.ExpandStr stz ENV.hMem Reset Intermediate string...
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.1 >STYA ZPPtr1
|
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
stz ENV.BufLen init Expanded String len=0
|
2019-07-22 06:31:01 +00:00
|
|
|
|
stz ENV.bExp No var found yet
|
2018-04-17 15:25:45 +00:00
|
|
|
|
stz ENV.bNoExp Reset no expand flag
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.10 jsr SHARED.GetCharPtr1 End of CSTR?
|
2019-09-09 15:38:37 +00:00
|
|
|
|
beq .80
|
2016-10-29 19:58:21 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.11 cmp #'''
|
2016-10-29 19:58:21 +00:00
|
|
|
|
bne .21
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda ENV.bNoExp
|
2016-10-29 19:58:21 +00:00
|
|
|
|
eor #$ff
|
2018-04-17 15:25:45 +00:00
|
|
|
|
sta ENV.bNoExp toggle flag
|
2019-09-10 10:22:57 +00:00
|
|
|
|
bra .10
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
.21 bit ENV.bNoExp
|
2017-04-01 21:01:28 +00:00
|
|
|
|
bpl .23
|
2016-10-29 19:58:21 +00:00
|
|
|
|
|
2018-05-07 06:13:07 +00:00
|
|
|
|
.22 jsr ENV.AddAToBuf
|
2019-09-10 10:22:57 +00:00
|
|
|
|
bra .10
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.23 cmp #'$' no, found one ?
|
2017-09-11 06:11:57 +00:00
|
|
|
|
bne .22 no, store...
|
|
|
|
|
|
2019-07-22 06:31:01 +00:00
|
|
|
|
ror ENV.bExp Toggle Expanded flag
|
2019-09-09 15:38:37 +00:00
|
|
|
|
lda (ZPPtr1)
|
2019-09-10 10:22:57 +00:00
|
|
|
|
bne .30
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
lda #'$' End of string, output $
|
|
|
|
|
bra .22
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.30 stz ENV.VarEndChar
|
|
|
|
|
cmp #'{' "${VAR]"?
|
2017-04-01 21:01:28 +00:00
|
|
|
|
bne .31
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
dec ENV.VarEndChar "}" expected
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
jsr SHARED.NextCharPtr1 skip "{"
|
|
|
|
|
bra .40
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.31 jsr ZP.IsDigit $0 ... $9 ?
|
|
|
|
|
bcs .32
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
and #$0f
|
|
|
|
|
|
|
|
|
|
jsr K.ArgV
|
2019-09-10 10:22:57 +00:00
|
|
|
|
bcs .35 Arg# is undefined, do not append anything
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
jsr ENV.AddYAToBuf
|
|
|
|
|
bra .35
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.32 ldx #ENV.SysVars.Cnt-1
|
2019-07-22 06:31:01 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.33 cmp ENV.SysVars,x
|
|
|
|
|
beq .34
|
|
|
|
|
dex
|
|
|
|
|
bpl .33
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
bra .40
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.34 jsr ENV.SysVar
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
2019-09-10 10:22:57 +00:00
|
|
|
|
.35 jsr SHARED.NextCharPtr1 skip $x
|
2019-09-09 15:38:37 +00:00
|
|
|
|
bra .10
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-09-10 06:28:08 +00:00
|
|
|
|
.40 jsr ENV.ExpandStrVar
|
2019-09-10 10:22:57 +00:00
|
|
|
|
bcc .70
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.50 jsr ENV.FindVarP1
|
2019-09-10 10:22:57 +00:00
|
|
|
|
bcs .70
|
2019-09-09 15:38:37 +00:00
|
|
|
|
jsr ENV.NextEnvP3
|
|
|
|
|
jsr ENV.AddP3ToBuf
|
2019-09-10 10:22:57 +00:00
|
|
|
|
|
|
|
|
|
.70 ldy #$ff
|
|
|
|
|
|
|
|
|
|
.71 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .72
|
|
|
|
|
jsr SHARED.IsIDValid
|
|
|
|
|
bcc .71
|
|
|
|
|
.72 jsr SHARED.AddYToPtr1
|
|
|
|
|
lda ENV.VarEndChar
|
2019-09-09 15:38:37 +00:00
|
|
|
|
beq .10
|
2019-09-10 10:22:57 +00:00
|
|
|
|
|
2019-10-12 14:20:09 +00:00
|
|
|
|
bra .35 skip "}" and loop
|
|
|
|
|
|
2019-07-22 06:31:01 +00:00
|
|
|
|
.80 lda ENV.hMem working from our temp string ?
|
2016-10-29 19:58:21 +00:00
|
|
|
|
beq .81 no...
|
2018-06-22 14:59:24 +00:00
|
|
|
|
jsr K.FreeMem yes, discard....
|
2016-10-29 19:58:21 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
.81 ldx ENV.BufLen
|
2017-09-08 14:49:23 +00:00
|
|
|
|
stz K.Buf256,x
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>LDYAI K.Buf256
|
2019-07-22 06:31:01 +00:00
|
|
|
|
jsr K.strdup
|
2019-09-09 06:25:27 +00:00
|
|
|
|
bcs K.FileSearch.RTS
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
2019-07-22 06:31:01 +00:00
|
|
|
|
stx ENV.hMem save this as temp string, in case of recurse
|
2019-10-12 14:20:09 +00:00
|
|
|
|
bit ENV.bExp Did we expand something ?
|
2019-09-09 06:25:27 +00:00
|
|
|
|
bpl K.FileSearch.RTS No, exit with Y,A from STRDUP
|
2019-10-12 14:20:09 +00:00
|
|
|
|
|
|
|
|
|
jmp .1 Yes, start over with ENV.hMem
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-28 15:26:34 +00:00
|
|
|
|
* # FileSearch
|
|
|
|
|
* Search a file in the provided PATH list
|
|
|
|
|
* And return, if found, the full path to it.
|
|
|
|
|
* ## C
|
|
|
|
|
* `int filesearch ( char * filename, char * searchpath, char * fullpath, stat * filestat);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHWI filestat`
|
|
|
|
|
* `>PUSHWI fullpath`
|
|
|
|
|
* `>PUSHWI searchpath`
|
|
|
|
|
* `>LDYAI filename`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-28 15:26:34 +00:00
|
|
|
|
* CC : success
|
|
|
|
|
* DstBuf = FilePath
|
|
|
|
|
* DstStat = S.STAT
|
|
|
|
|
* CS : not found
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FileSearch pha
|
2019-01-04 13:17:31 +00:00
|
|
|
|
>PULLW ENV.SearchPath
|
2018-06-28 15:26:34 +00:00
|
|
|
|
>PULLW .2+1 DstBuf
|
|
|
|
|
>PULLW .4+1 DstStat
|
|
|
|
|
pla Y,A = filename
|
2019-01-21 06:52:04 +00:00
|
|
|
|
jsr ENV.Search.YA
|
|
|
|
|
bcs K.FileSearch.RTS
|
2018-06-28 15:26:34 +00:00
|
|
|
|
ldx #$ff
|
|
|
|
|
.1 inx
|
|
|
|
|
lda K.Buf256,x
|
|
|
|
|
.2 sta $ffff,x Self Modified
|
|
|
|
|
bne .1
|
|
|
|
|
ldx #S.STAT-1
|
2019-10-03 06:25:27 +00:00
|
|
|
|
.3 lda K.S.STAT,x
|
2018-06-28 15:26:34 +00:00
|
|
|
|
.4 sta $ffff,x Self Modified
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
2019-10-03 06:25:27 +00:00
|
|
|
|
* clc
|
2019-01-21 06:52:04 +00:00
|
|
|
|
K.FileSearch.RTS
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ENV.Search.LIB ldx #0
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
ENV.Search.DRV ldx #2
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
ENV.Search.PATH ldx #4
|
|
|
|
|
|
2019-01-22 16:35:42 +00:00
|
|
|
|
>STYA ZPPtr2
|
2019-01-21 06:52:04 +00:00
|
|
|
|
>LDYA ENV.VARS,x
|
2019-01-22 16:35:42 +00:00
|
|
|
|
jsr K.GetEnv get value for Search Path
|
2019-01-21 06:52:04 +00:00
|
|
|
|
bcs K.FileSearch.RTS
|
|
|
|
|
>STYA ENV.SearchPath
|
2018-06-28 15:26:34 +00:00
|
|
|
|
|
2019-01-22 16:35:42 +00:00
|
|
|
|
>LDYA ZPPtr2
|
2019-01-21 06:52:04 +00:00
|
|
|
|
ENV.Search.YA >STYA .4+1
|
2018-07-16 05:52:52 +00:00
|
|
|
|
|
2019-01-04 13:17:31 +00:00
|
|
|
|
>LDYA ENV.SearchPath
|
2018-07-16 05:52:52 +00:00
|
|
|
|
jsr K.ExpandStr Y,A = Search Path, Expand it
|
2018-06-28 15:26:34 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
stx .98+1
|
|
|
|
|
>STYA .2+1 expanded search list ;
|
|
|
|
|
stz .1+1
|
|
|
|
|
|
|
|
|
|
.1 ldy #$0 Self Modified Index in Search list string
|
|
|
|
|
ldx #$0
|
|
|
|
|
.2 lda $ffff,y Self Modified, Search list string
|
|
|
|
|
beq .3 end of string, try it....
|
|
|
|
|
iny
|
2018-11-17 17:17:13 +00:00
|
|
|
|
cmp #':'
|
2018-06-28 15:26:34 +00:00
|
|
|
|
beq .3
|
|
|
|
|
sta K.Buf256,x
|
|
|
|
|
inx
|
|
|
|
|
bra .2
|
|
|
|
|
.3 txa
|
|
|
|
|
beq .98 String is empty....nothing to try
|
|
|
|
|
|
|
|
|
|
sty .1+1 save current index
|
|
|
|
|
ldy #$0
|
|
|
|
|
.4 lda $ffff,y Self Modified, Append Filename...
|
|
|
|
|
sta K.Buf256,x
|
|
|
|
|
beq .5
|
|
|
|
|
iny
|
|
|
|
|
inx
|
|
|
|
|
bra .4
|
2019-12-02 16:47:53 +00:00
|
|
|
|
|
2019-05-04 21:13:50 +00:00
|
|
|
|
.5 >PUSHWI K.S.STAT
|
|
|
|
|
>LDYAI K.Buf256
|
2019-12-02 16:47:53 +00:00
|
|
|
|
>SYSCALL2 stat
|
2018-06-28 15:26:34 +00:00
|
|
|
|
bcs .1 Failed...retry next path...
|
2019-12-02 16:47:53 +00:00
|
|
|
|
|
2018-06-28 15:26:34 +00:00
|
|
|
|
lda K.S.STAT+S.STAT.P.TYPE
|
|
|
|
|
cmp #S.FI.T.DIR Dir ?
|
|
|
|
|
beq .1
|
|
|
|
|
jsr .98 Discard Expanded hSrch list
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
|
|
|
|
|
|
|
|
|
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
|
|
|
|
|
jsr K.FreeMem
|
2019-07-08 15:39:14 +00:00
|
|
|
|
|
2018-06-28 15:26:34 +00:00
|
|
|
|
lda #MLI.E.FNOTFND
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* # PutEnv
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* Change or add an environment variable, string is 'NAME=VALUE'
|
|
|
|
|
* ## C
|
|
|
|
|
* `int putenv(char *string);`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* `>LDYA string`
|
|
|
|
|
* `>SYSCALL putenv`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*\--------------------------------------
|
2019-07-08 15:39:14 +00:00
|
|
|
|
K.PutEnv >STYA ZPPtr2 NAME=VALUE
|
2016-12-03 22:16:45 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ldy #0
|
2019-07-08 15:39:14 +00:00
|
|
|
|
.1 lda (ZPPtr2),y copy NAME to K.Buf256
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq .9
|
2017-08-30 15:26:34 +00:00
|
|
|
|
cmp #'='
|
|
|
|
|
beq .2
|
|
|
|
|
sta K.Buf256,y
|
|
|
|
|
iny
|
|
|
|
|
bne .1
|
2019-07-08 15:39:14 +00:00
|
|
|
|
.9 lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-08-30 15:26:34 +00:00
|
|
|
|
.2 lda #0
|
|
|
|
|
sta K.Buf256,y
|
2016-12-03 22:16:45 +00:00
|
|
|
|
|
2019-07-28 20:39:30 +00:00
|
|
|
|
jsr SHARED.AddYp1ToPtr2
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2017-08-30 15:26:34 +00:00
|
|
|
|
>LDYAI K.Buf256
|
|
|
|
|
>STYA ZPPtr1
|
2017-10-27 14:56:46 +00:00
|
|
|
|
bra K.SetEnv.I
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*/--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
* # SetEnv
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* Change or add an environment variable
|
|
|
|
|
* ## C
|
|
|
|
|
* `int setenv(const char *name, const char *value);`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* `>PUSHW value`
|
|
|
|
|
* `>LDYA name`
|
|
|
|
|
* `>SYSCALL setenv`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*\--------------------------------------
|
2019-07-28 20:39:30 +00:00
|
|
|
|
K.SetEnv jsr SHARED.SPtr1PPtr2
|
2017-10-27 14:56:46 +00:00
|
|
|
|
K.SetEnv.I jsr K.UnsetEnv.I
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2019-01-22 16:35:42 +00:00
|
|
|
|
.1 jsr ENV.InitEnvP3 ZPPtr3 -> Env
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-01-25 15:15:19 +00:00
|
|
|
|
lda #1
|
|
|
|
|
sta ZPPtr4
|
|
|
|
|
stz ZPPtr4+1 ZPPtr4 = ENVSIZE = 1
|
2017-09-11 06:11:57 +00:00
|
|
|
|
.10 lda (ZPPtr3) End of ENV
|
|
|
|
|
beq .15
|
2019-01-25 15:15:19 +00:00
|
|
|
|
jsr ENV.GetP3LenY
|
|
|
|
|
jsr ENV.NextEnvP3Y
|
|
|
|
|
jsr ENV.NextEnvP4Y
|
2017-09-11 06:11:57 +00:00
|
|
|
|
bra .10
|
|
|
|
|
|
2019-01-25 15:15:19 +00:00
|
|
|
|
.15 ldy #$ff
|
2019-01-23 16:26:48 +00:00
|
|
|
|
.16 iny
|
|
|
|
|
lda (ZPPtr1),y
|
2017-09-11 06:11:57 +00:00
|
|
|
|
bne .16
|
2019-01-25 15:15:19 +00:00
|
|
|
|
jsr ENV.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2018-10-29 08:41:10 +00:00
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.19 iny
|
|
|
|
|
lda (ZPPtr2),y
|
2017-09-11 06:11:57 +00:00
|
|
|
|
bne .19
|
2019-01-25 15:15:19 +00:00
|
|
|
|
jsr ENV.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE
|
|
|
|
|
lda ZPPtr4
|
|
|
|
|
beq .20
|
2017-09-11 06:11:57 +00:00
|
|
|
|
inc ZPPtr4+1
|
2019-01-25 15:15:19 +00:00
|
|
|
|
.20 ldy #S.PS.ENVPAGECNT
|
2019-01-22 16:35:42 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
cmp ZPPtr4+1
|
|
|
|
|
bcs .22 env is large enough
|
|
|
|
|
|
2019-01-25 15:15:19 +00:00
|
|
|
|
lda ZPPtr4+1
|
|
|
|
|
jsr ENV.Dup.A
|
2019-01-22 16:35:42 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
pha
|
|
|
|
|
ldy #S.PS.hENV
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
jsr K.Freemem
|
|
|
|
|
pla
|
|
|
|
|
ldy #S.PS.hENV
|
|
|
|
|
sta (pPs),y
|
|
|
|
|
txa
|
|
|
|
|
dey S.PS.ENVPAGECNT
|
|
|
|
|
sta (pPs),y
|
|
|
|
|
bra .1 Start over
|
|
|
|
|
.22 ldy #$ff
|
|
|
|
|
.23 iny
|
2017-09-11 06:11:57 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr3),y
|
2019-01-22 16:35:42 +00:00
|
|
|
|
bne .23
|
2018-10-29 08:41:10 +00:00
|
|
|
|
jsr ENV.NextEnvP3Y
|
|
|
|
|
ldy #$ff
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
|
|
|
|
.24 iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
bne .24
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPPtr3),y don't forget array ending 0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
2019-01-22 16:35:42 +00:00
|
|
|
|
.9 rts
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* # GetEnv
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* searches the environment list to find the environment variable name,
|
|
|
|
|
* and returns a pointer to the corresponding value string.
|
|
|
|
|
* ## C
|
|
|
|
|
* `char *getenv(const char *name);`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* `>LDYA name`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* `>SYSCALL getenv`
|
|
|
|
|
* ## RETURN VALUE
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* CC : Y,A = PTR to VALUE (C-String)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* CS : not found
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
K.GetEnv >STYA ZPPtr1
|
2017-10-27 14:56:46 +00:00
|
|
|
|
jsr ENV.FindVarP1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
2017-10-27 14:56:46 +00:00
|
|
|
|
jsr ENV.NextEnvP3 Skip NAME
|
2019-01-26 14:01:05 +00:00
|
|
|
|
clc just in case ADC in NextEnvPtr3 disturb CC
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.9 >LDYA ZPPtr3 \0
|
2016-10-29 19:58:21 +00:00
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* # UnsetEnv
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* Remove an environment variable
|
|
|
|
|
* ## C
|
|
|
|
|
* `int unsetenv(const char *name);`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-09-06 15:36:44 +00:00
|
|
|
|
* `>LDYA name`
|
|
|
|
|
* `>SYSCALL unsetenv`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
K.UnsetEnv >STYA ZPPtr1 Store VAR Name
|
2017-10-27 14:56:46 +00:00
|
|
|
|
K.UnsetEnv.I jsr ENV.FindVarP1
|
2018-04-17 15:25:45 +00:00
|
|
|
|
bcs K.UnsetEnv.I.8 not found, quit
|
2015-11-10 21:47:57 +00:00
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
jsr ENV.DelVarP3 Ptr3 -> ENVNAME
|
2018-04-17 15:25:45 +00:00
|
|
|
|
K.UnsetEnv.I.8 clc
|
2018-05-07 14:59:51 +00:00
|
|
|
|
K.UnsetEnv.I.9 rts
|
2015-11-10 21:47:57 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* PRIVATE
|
|
|
|
|
*--------------------------------------
|
2019-09-09 15:38:37 +00:00
|
|
|
|
ENV.SysVarsAllArgs
|
|
|
|
|
lda #1
|
2019-07-22 06:31:01 +00:00
|
|
|
|
jsr K.ArgV
|
|
|
|
|
bcs ENV.SysVarsNum.8
|
|
|
|
|
>STYA ZPPtr3
|
2019-09-08 12:09:47 +00:00
|
|
|
|
|
2019-07-22 06:31:01 +00:00
|
|
|
|
.1 lda (ZPPtr3)
|
2019-09-08 12:09:47 +00:00
|
|
|
|
beq ENV.SysVarsNum.8
|
2019-07-22 06:31:01 +00:00
|
|
|
|
|
|
|
|
|
.2 jsr ENV.AddP3ToBuf
|
|
|
|
|
jsr ENV.NextEnvP3
|
|
|
|
|
lda (ZPPtr3)
|
2019-09-08 12:09:47 +00:00
|
|
|
|
beq ENV.SysVarsNum.8
|
2019-07-22 06:31:01 +00:00
|
|
|
|
lda #' '
|
|
|
|
|
jsr ENV.AddAToBuf
|
|
|
|
|
bra .2
|
2018-05-07 06:13:07 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-10 10:22:57 +00:00
|
|
|
|
ENV.SysVar txa
|
|
|
|
|
beq ENV.SysVarsAllArgs
|
|
|
|
|
|
|
|
|
|
ldy ENV.SysVars.PS-1,x
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
*--------------------------------------
|
2019-07-22 06:31:01 +00:00
|
|
|
|
ENV.SysVarsNum jsr MATH.A2STR10NP
|
|
|
|
|
ldy #0
|
|
|
|
|
.1 lda A2osX.NumStrBuf,y
|
|
|
|
|
beq ENV.SysVarsNum.8
|
|
|
|
|
iny
|
|
|
|
|
jsr ENV.AddAToBuf
|
|
|
|
|
bra .1
|
|
|
|
|
ENV.SysVarsNum.8
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-10-29 19:58:21 +00:00
|
|
|
|
*--------------------------------------
|
2019-07-22 06:31:01 +00:00
|
|
|
|
ENV.SysVars .AS "*#?@$!"
|
|
|
|
|
ENV.SysVars.Cnt .EQ *-ENV.SysVars
|
|
|
|
|
ENV.SysVars.PS .DA #S.PS.ARGC,#S.PS.RC,#S.PS.PPID,#S.PS.PID,#S.PS.CPID
|
2018-11-28 14:58:42 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-10 06:28:08 +00:00
|
|
|
|
ENV.ExpandStrVar
|
|
|
|
|
>LDYAI ENV.StrVars
|
|
|
|
|
>STYA ZPPtr3
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtr3)
|
|
|
|
|
beq .9
|
|
|
|
|
|
2019-10-03 06:25:27 +00:00
|
|
|
|
ldy #$ff
|
2019-09-10 06:28:08 +00:00
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .3
|
|
|
|
|
jsr SHARED.IsIDValid
|
|
|
|
|
bcs .3
|
|
|
|
|
cmp (ZPPtr3),y
|
|
|
|
|
beq .2
|
|
|
|
|
bra .4
|
|
|
|
|
|
|
|
|
|
.3 lda (ZPPtr3),y
|
|
|
|
|
bne .4
|
|
|
|
|
jmp (ENV.StrVarsJmp,x)
|
|
|
|
|
.4 inx
|
|
|
|
|
inx
|
|
|
|
|
jsr ENV.NextEnvP3
|
|
|
|
|
bra .1
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-09-09 15:38:37 +00:00
|
|
|
|
ENV.StrVars .AZ "LOGNAME"
|
|
|
|
|
.AZ "GECOS"
|
|
|
|
|
.AZ "HOME"
|
|
|
|
|
.AZ "SHELL"
|
|
|
|
|
.AZ "PWD"
|
|
|
|
|
.AZ "UID"
|
|
|
|
|
.AZ "GID"
|
|
|
|
|
.DA #0
|
|
|
|
|
*--------------------------------------
|
2019-04-15 15:29:07 +00:00
|
|
|
|
ENV.StrVarsJmp .DA ENV.StrVarsSession
|
|
|
|
|
.DA ENV.StrVarsSession
|
|
|
|
|
.DA ENV.StrVarsSession
|
|
|
|
|
.DA ENV.StrVarsSession
|
|
|
|
|
.DA ENV.StrVarsPWD
|
2018-11-28 14:58:42 +00:00
|
|
|
|
.DA ENV.StrVarsUID
|
2019-04-15 15:29:07 +00:00
|
|
|
|
.DA ENV.StrVarsGID
|
2018-11-28 14:58:42 +00:00
|
|
|
|
*--------------------------------------
|
2019-07-22 16:28:44 +00:00
|
|
|
|
ENV.StrVarsPWD ldy #S.PS.hCWD
|
2018-11-28 14:58:42 +00:00
|
|
|
|
lda (pPS),y
|
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
jmp ENV.AddYAToBuf
|
|
|
|
|
*--------------------------------------
|
2019-04-16 15:54:56 +00:00
|
|
|
|
ENV.StrVarsUID ldy #S.SESSION.UID
|
2018-11-28 14:58:42 +00:00
|
|
|
|
.HS 2C
|
2019-04-16 15:54:56 +00:00
|
|
|
|
ENV.StrVarsGID ldy #S.SESSION.GID
|
2019-04-15 15:29:07 +00:00
|
|
|
|
lda (pSession),y
|
2019-09-10 06:28:08 +00:00
|
|
|
|
jmp ENV.SysVarsNum
|
2019-04-15 15:29:07 +00:00
|
|
|
|
ENV.StrVarsSession
|
|
|
|
|
lda pSession
|
|
|
|
|
clc
|
2019-04-16 15:54:56 +00:00
|
|
|
|
adc #S.SESSION.NAME
|
2019-04-15 15:29:07 +00:00
|
|
|
|
sta ZPPtr3
|
|
|
|
|
lda pSession+1
|
2019-04-16 15:54:56 +00:00
|
|
|
|
adc /S.SESSION.NAME
|
2019-04-15 15:29:07 +00:00
|
|
|
|
sta ZPPtr3+1
|
|
|
|
|
|
|
|
|
|
.1 dex
|
|
|
|
|
dex
|
|
|
|
|
bmi .3
|
|
|
|
|
ldy #$ff
|
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr3),y
|
|
|
|
|
bne .2
|
2019-07-17 15:49:23 +00:00
|
|
|
|
jsr ENV.NextEnvP3Y
|
2019-04-15 15:29:07 +00:00
|
|
|
|
bra .1
|
|
|
|
|
.3 jmp ENV.AddP3ToBuf
|
2017-04-03 06:01:52 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
* ENV.FindVarP1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* In:
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* ZPPtr1 -> NAME
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* Out:
|
|
|
|
|
* CC: Found
|
2019-09-09 15:38:37 +00:00
|
|
|
|
* Y = NAME len
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* ZPPtr1 -> NAME
|
|
|
|
|
* ZPPtr3 -> ENV.NAME
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* CS: Not Found
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* ZPPtr1 -> NAME
|
|
|
|
|
* ZPPtr3 -> PTR to Ending 0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
ENV.FindVarP1 jsr ENV.InitEnvP3 Store ENV
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2017-08-30 15:26:34 +00:00
|
|
|
|
.1 lda (ZPPtr3)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq .9 end of ENV
|
2018-10-26 14:46:11 +00:00
|
|
|
|
ldy #$ff
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2018-10-26 14:46:11 +00:00
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr1),y
|
2019-09-09 15:38:37 +00:00
|
|
|
|
beq .3
|
|
|
|
|
jsr SHARED.IsIDValid
|
|
|
|
|
bcs .3
|
2017-01-12 17:43:45 +00:00
|
|
|
|
cmp (ZPPtr3),y
|
2019-09-09 15:38:37 +00:00
|
|
|
|
beq .2
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
bra .4
|
|
|
|
|
.3 lda (ZPPtr3),y
|
|
|
|
|
bne .4
|
|
|
|
|
|
2019-07-22 06:31:01 +00:00
|
|
|
|
clc
|
2016-08-17 06:25:58 +00:00
|
|
|
|
rts
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2019-09-09 15:38:37 +00:00
|
|
|
|
.4 jsr ENV.NextEnvP3x2 Skip NAME & VALUE
|
2017-08-30 15:26:34 +00:00
|
|
|
|
bra .1
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.9 sec
|
2017-09-14 15:21:06 +00:00
|
|
|
|
rts
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
* ENV.DelVarP3
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* In:
|
2017-01-12 17:43:45 +00:00
|
|
|
|
* ZPPtr3 -> ENV.NAME to Discard
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
ENV.DelVarP3 >LDYA ZPPtr3 save actual Ptr
|
2017-08-30 15:26:34 +00:00
|
|
|
|
>STYA ZPPtr4
|
2019-01-26 14:01:05 +00:00
|
|
|
|
jsr ENV.NextEnvP3x2 Skip NAME & VALUE
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2018-10-29 08:41:10 +00:00
|
|
|
|
.1 ldy #$ff
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2018-10-29 08:41:10 +00:00
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr3),y Move back CSTRs...
|
2017-09-11 06:11:57 +00:00
|
|
|
|
sta (ZPPtr4),y
|
2018-10-29 08:41:10 +00:00
|
|
|
|
bne .2
|
|
|
|
|
tya
|
2019-07-22 06:31:01 +00:00
|
|
|
|
beq ENV.InitEnvP3.RTS we moved back ending \0
|
2018-10-29 08:41:10 +00:00
|
|
|
|
jsr ENV.NextEnvP3Y
|
|
|
|
|
jsr ENV.NextEnvP4Y
|
|
|
|
|
bra .1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
ENV.InitEnvP3 ldy #S.PS.hENV
|
2016-08-17 06:25:58 +00:00
|
|
|
|
lda (pPs),y
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2017-09-14 15:21:06 +00:00
|
|
|
|
>STYA ZPPtr3 Store ENV
|
2019-07-22 06:31:01 +00:00
|
|
|
|
ENV.InitEnvP3.RTS
|
2016-08-17 06:25:58 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-01-26 14:01:05 +00:00
|
|
|
|
ENV.NextEnvP3x2 jsr ENV.NextEnvP3
|
|
|
|
|
*--------------------------------------
|
2019-01-25 15:15:19 +00:00
|
|
|
|
ENV.NextEnvP3 jsr ENV.GetP3LenY
|
2019-01-26 14:01:05 +00:00
|
|
|
|
*--------------------------------------
|
2018-10-29 08:41:10 +00:00
|
|
|
|
ENV.NextEnvP3Y tya
|
2019-07-17 15:49:23 +00:00
|
|
|
|
ENV.NextEnvP3A sec
|
2017-08-30 15:26:34 +00:00
|
|
|
|
adc ZPPtr3
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta ZPPtr3
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcc .8
|
2017-01-12 17:43:45 +00:00
|
|
|
|
inc ZPPtr3+1
|
2017-09-11 06:11:57 +00:00
|
|
|
|
.8 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2019-01-25 15:15:19 +00:00
|
|
|
|
ENV.GetP3LenY ldy #$ff
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr3),y
|
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-10-29 08:41:10 +00:00
|
|
|
|
ENV.NextEnvP4Y tya
|
|
|
|
|
sec
|
|
|
|
|
adc ZPPtr4
|
|
|
|
|
sta ZPPtr4
|
|
|
|
|
bcc .8
|
|
|
|
|
inc ZPPtr4+1
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2019-09-10 06:28:08 +00:00
|
|
|
|
ENV.AddYAToBuf >STYA ZPPtr3
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ENV.AddP3ToBuf ldx ENV.BufLen
|
|
|
|
|
ldy #$ff
|
|
|
|
|
dex
|
|
|
|
|
.1 iny
|
|
|
|
|
inx
|
|
|
|
|
lda (ZPPtr3),y
|
|
|
|
|
sta K.Buf256,x
|
|
|
|
|
bne .1
|
|
|
|
|
stx ENV.BufLen
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-05-07 06:13:07 +00:00
|
|
|
|
ENV.AddAToBuf ldx ENV.BufLen
|
|
|
|
|
sta K.Buf256,x
|
2018-05-07 14:59:51 +00:00
|
|
|
|
inc ENV.BufLen
|
2018-05-07 06:13:07 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-01-22 16:35:42 +00:00
|
|
|
|
* ENV.Dup
|
|
|
|
|
* In:
|
|
|
|
|
* A = ENV hMem To Duplicate
|
|
|
|
|
* Out:
|
|
|
|
|
* A = hMem to new ENV
|
|
|
|
|
* X = Page Count
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
ENV.Dup ldy #S.PS.ENVPAGECNT
|
|
|
|
|
lda (pPs),y
|
2019-01-25 15:15:19 +00:00
|
|
|
|
ENV.Dup.A sta .8+1 Store target page Count
|
2019-01-22 16:35:42 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
jsr K.GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA .2+1 Target Buffer
|
|
|
|
|
phx save hMem
|
2019-07-18 15:55:43 +00:00
|
|
|
|
jsr Mem.SetOwner Set Ownership
|
2019-01-22 16:35:42 +00:00
|
|
|
|
ldy #S.PS.hENV
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
>STYA .1+1
|
2019-01-25 15:15:19 +00:00
|
|
|
|
ldy #S.PS.ENVPAGECNT get SOURCE page count
|
2019-01-22 16:35:42 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
tax
|
|
|
|
|
ldy #0
|
|
|
|
|
.1 lda $ffff,y SELF MODIFIED
|
|
|
|
|
.2 sta $ffff,y SELF MODIFIED
|
|
|
|
|
iny
|
|
|
|
|
bne .1
|
|
|
|
|
inc .1+2
|
|
|
|
|
inc .2+2
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
2019-01-25 15:15:19 +00:00
|
|
|
|
.8 ldx #$ff SELF MODIFIED Target Page Count
|
2019-01-22 16:35:42 +00:00
|
|
|
|
pla hMem
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2019-01-21 06:52:04 +00:00
|
|
|
|
ENV.VARS .DA .1
|
|
|
|
|
.DA .2
|
|
|
|
|
.DA .3
|
|
|
|
|
.1 .AZ "LIB"
|
|
|
|
|
.2 .AZ "DRV"
|
|
|
|
|
.3 .AZ "PATH"
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SYS/KERNEL.S.ENV
|
|
|
|
|
LOAD USR/SRC/SYS/KERNEL.S
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|